Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 4615

How to solve problem with VideoCapture loading in linux ?

$
0
0
Hi, I've written the following code so as to load a mp4 video into VideoCapture, however, when I check the capture with `isOpened()` I get false . I'm 100% sure that the mp4 file is within the folder but my code is not able to open the capture. #include // for standard I/O #include // Basic OpenCV structures (cv::Mat, Scalar) #include // Gaussian Blur #include // OpenCV window I/O #include #include using namespace std; using namespace cv; int loadVideo( VideoCapture cap1, int seek_step,int thrd){ int frameNum = 0; Mat frame; char c; cap1.set(CV_CAP_PROP_POS_FRAMES, seek_step ); while (1){ cap1 >> frame; if (frame.empty()) { cout << " <<< Channel stream ended! >>> "; break; } cout << frameNum << endl; ++frameNum; } return frameNum; } int main(int argc, char *argv[]) { string sourceVideoPath; sourceVideoPath = "/home/azdoud/case1_320_200/case320_200fps20.mp4"; // sourceVideoPath = "case320_240fps20.mp4"; // sourceVideoPath = "C:\\opencvVid\\case1_320_240\\vid320_240fps25.mp4"; // sourceVideoPath = argv[1]; //start a new VideoCapture object in each of your 4 threads VideoCapture cap1(sourceVideoPath); cout << "Stream frame numbre : " << cap1.get(CV_CAP_PROP_FRAME_COUNT)< #include #include #include #include using namespace std; using namespace cv; int main() { Mat src; /// Load image src = imread( "/home/azdoud/im.jpg"); // src = imread( "C:\\opencvVid\\images\\1.png" ); cout << "Width : " << src.size().width << endl; cout << "Height: " << src.size().height << endl; return 0; } this the result [azdoud@video-processor CentOSsimple]$ cmake -DCMAKE_CXX_FLAGS="-std=c++11" -- Configuring done -- Generating done -- Build files have been written to: /home/azdoud/CentOSsimple [azdoud@video-processor CentOSsimple]$ make Scanning dependencies of target main [100%] Building CXX object CMakeFiles/main.dir/main.cpp.o Linking CXX executable main [100%] Built target main [azdoud@video-processor CentOSsimple]$ ./main Width : 0 Height: 0 you may tell is a probelm of permission, I've checked that too by setting chmod to 666 on the folder and on mp4 file. How can you explain this, I can't understand why any help thank you in advance. here the `getBuildInformation()` output [azdoud@video-processor CentOSsimple]$ cmake -DCMAKE_CXX_FLAGS="-std=c++11" -- Configuring done -- Generating done -- Build files have been written to: /home/azdoud/CentOSsimple [azdoud@video-processor CentOSsimple]$ make Scanning dependencies of target main [100%] Building CXX object CMakeFiles/main.dir/main.cpp.o Linking CXX executable main [100%] Built target main [azdoud@video-processor CentOSsimple]$ ./main Built info General configuration for OpenCV 2.4.8.2 ===================================== Version control: 2.4.8.2 Platform: Host: Linux 3.10.0-693.21.1.el7.x86_64 x86_64 CMake: 2.8.12.2 CMake generator: Unix Makefiles CMake build tool: /bin/gmake Configuration: RELEASE C/C++: Built as dynamic libs?: YES C++ Compiler: /bin/c++ (ver 4.8.5) C++ flags (Release): -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -DNDEBUG C++ flags (Debug): -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O0 -DDEBUG -D_DEBUG C Compiler: /bin/cc C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG -DNDEBUG C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG Linker flags (Release): Linker flags (Debug): Precompiled headers: YES 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 GUI: QT: NO GTK+ 2.x: YES (ver 2.24.31) GThread : YES (ver 2.54.2) GtkGlExt: NO OpenGL support: NO Media I/O: ZLib: /lib64/libz.so (ver 1.2.7) JPEG: libjpeg (ver 62) PNG: /lib64/libpng.so (ver 1.5.13) TIFF: build (ver 42 - 4.0.2) JPEG 2000: build (ver 1.900.1) OpenEXR: build (ver 1.7.1) Video I/O: DC1394 1.x: NO DC1394 2.x: NO FFMPEG: NO codec: NO format: NO util: NO swscale: NO gentoo-style: NO GStreamer: NO OpenNI: NO OpenNI PrimeSensor Modules: NO PvAPI: NO GigEVisionSDK: NO UniCap: NO UniCap ucil: NO V4L/V4L2: NO/YES XIMEA: NO Xine: NO Other third-party libraries: Use IPP: NO Use Eigen: NO Use TBB: NO Use OpenMP: NO Use GCD NO Use Concurrency NO Use C=: NO Use Cuda: NO Use OpenCL: YES OpenCL: Version: dynamic Include path: /opt/working/opencv/3rdparty/include/opencl/1.2 Use AMD FFT: NO Use AMD BLAS: NO Python: Interpreter: /bin/python2 (ver 2.7.5) Java: ant: NO JNI: NO Java tests: NO Documentation: Build Documentation: NO Sphinx: NO PdfLaTeX compiler: NO Tests and samples: Tests: YES Performance tests: YES C/C++ Examples: NO Install path: /usr/local cvconfig.h is in: /opt/working/opencv/release ----------------------------------------------------------------- Stream frame numbre : 0 Could not open video case320_240fps20.mp4

Viewing all articles
Browse latest Browse all 4615

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>