简体   繁体   中英

cannot load a VIDEO with opencv c++

i'm trying to load a video in c++ by using VideoCapture ( I'm using windows)...

the video name is 'A.avi' and this is the path "C:\Users\anton\Desktop\eyeVideos"

searching online I found that the path should by inserted like this: C:/Users/anton/Desktop/eyeVideos/

I'm using a code that I found online:

VideoCapture capture("C:/Users/anton/Desktop/eyeVideos/A.avi");
if(!capture.isOpened()){
std::`cout<<"cannot read video!\n";`
return -1;

}

the problem is that using breakpoints the code is always stopped at this point cout<<"cannot read video;\n"; I found a similar question here on stackoverflow but I didn't understand the solution ( sorry but I'm a super beginner) thanks in advance

this is the output of getBuildInformation();

   General configuration for OpenCV 2.4.13.7 =====================================
  Version control:               unknown

  Platform:
    Timestamp:                   2020-12-10T20:59:23Z
    Host:                        Windows 10.0.19041 AMD64
    CMake:                       3.18.4
    CMake generator:             Ninja
    CMake build tool:            C:/DEV/vcpkg-master/downloads/tools/ninja/1.10.1-windows/ninja.exe
    MSVC:                        1916
    Configuration:               Debug

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe  (ver 19.16.27044.0)
    C++ flags (Release):         /nologo /DWIN32 /D_WINDOWS /W4 /utf-8 /GR /EHs /MP  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /wd4251 /wd4275 /wd4589 /wd4359 /MP4  /MD /O2 /Oi /Gy /DNDEBUG /Z7
    C++ flags (Debug):           /nologo /DWIN32 /D_WINDOWS /W4 /utf-8 /GR /EHs /MP  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /wd4251 /wd4275 /wd4589 /wd4359 /MP4  /D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
    C flags (Release):           /nologo /DWIN32 /D_WINDOWS /W3 /utf-8 /MP   /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi    /MP4  /MD /O2 /Oi /Gy /DNDEBUG /Z7
    C flags (Debug):             /nologo /DWIN32 /D_WINDOWS /W3 /utf-8 /MP   /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi    /MP4  /D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1
    Linker flags (Release):      /machine:x64  /nologo /DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF    /debug
    Linker flags (Debug):        /machine:x64  /nologo    /debug /INCREMENTAL
    ccache:                      NO
    Precompiled headers:         NO

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda java python viz

  Windows RT support:            NO

  GUI:
    QT:                          NO
    Win32 UI:                    YES
    OpenGL support:              YES (opengl32 glu32)
    VTK support:                 NO

  Media I/O:
    ZLib:                        optimized C:/DEV/vcpkg-master/installed/x64-windows/lib/zlib.lib debug C:/DEV/vcpkg-master/installed/x64-windows/debug/lib/zlibd.lib (ver 1.2.11)
    JPEG:                        optimized C:/DEV/vcpkg-master/installed/x64-windows/lib/jpeg.lib debug C:/DEV/vcpkg-master/installed/x64-windows/debug/lib/jpegd.lib (ver )
    PNG:                         optimized C:/DEV/vcpkg-master/installed/x64-windows/lib/libpng16.lib debug C:/DEV/vcpkg-master/installed/x64-windows/debug/lib/libpng16d.lib (ver 1.6.37)
    TIFF:                        optimized C:/DEV/vcpkg-master/installed/x64-windows/lib/tiff.lib debug C:/DEV/vcpkg-master/installed/x64-windows/debug/lib/tiffd.lib optimized C:/DEV/vcpkg-master/installed/x64-windows/lib/lzma.lib debug C:/DEV/vcpkg-master/installed/x64-windows/debug/lib/lzmad.lib optimized C:/DEV/vcpkg-master/installed/x64-windows/lib/jpeg.lib debug C:/DEV/vcpkg-master/installed/x64-windows/debug/lib/jpegd.lib optimized C:/DEV/vcpkg-master/installed/x64-windows/lib/zlib.lib debug C:/DEV/vcpkg-master/installed/x64-windows/debug/lib/zlibd.lib (ver 42 - 4.1.0)
    JPEG 2000:                   NO
    OpenEXR:                     NO

  Video I/O:
    Video for Windows:           YES
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      NO
      avcodec:                   NO
      avformat:                  NO
      avutil:                    NO
      swscale:                   NO
      avresample:                NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    DirectShow:                  YES
    Media Foundation:            YES
    XIMEA:                       NO
    Intel PerC:                  NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.3.7)
    Use TBB:                     NO
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              YES
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Include path:                C:/DEV/vcpkg-master/buildtrees/opencv2/src/2.4.13.7-64eb3208d2.clean/3rdparty/include/opencl/1.2
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 NO

  Java:
    ant:                         NO
    JNI:                         NO
    Java tests:                  NO

  Tests and samples:
    Tests:                       NO
    Performance tests:           NO
    C/C++ Examples:              NO

  Install path:                  C:/DEV/vcpkg-master/packages/opencv2_x64-windows/debug

  cvconfig.h is in:              C:/DEV/vcpkg-master/buildtrees/opencv2/x64-windows-dbg
-----------------------------------------------------------------


`

your build information says that your build doesn't use ffmpeg. I don't know if DirectShow or MSMF is enough to read videos (it should be but OpenCV might only use it for camera access).

you need to get a build of OpenCV that is built with FFMPEG support. maybe the official download on opencv.org is suitable. if not, you will need to build OpenCV yourself. if you were using python, I'd have advised to pip install opencv-python , which is a rather full-featured build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM