openCV 3.1.0 videocapture can't open a video [closed]

asked 2016-06-13 08:27:42 -0500

federocchi gravatar image

updated 2016-06-13 10:03:33 -0500

Hello, I've installed opencv 3.1.0, building on my own with visual studio 2010 and everything is working but videocapture, compiling but not running; I've tried all I could find on the net (updated K-lite codecs and put the opencv_ffmpeg310_64.dll in the compiler directory C:\opencv\build\x64\vc10\bin)

The simple test code I'm using:

#include <iostream> #include <fstream> #include <opencv2 videoio.hpp=""> #include <opencv2 highgui.hpp=""> #include <opencv2 imgproc.hpp=""> using namespace cv; using namespace std;

int main(int argc, char** argv) {

Mat imagex;
imagex = imread("C:/opencv/data/test.png", IMREAD_COLOR); // Read the file     

if( imagex.empty() ) // Check for invalid input     
    cout << "Could not open or find the image" << std::endl ;         
    return -3;

cout << "image opened" << std::endl ;

 ifstream myfile; ("C:/opencv/data/pictCh0_0.yuv", ios::binary|ios::ate); //open the yuv422 file

 if (!myfile.is_open()) { 
    fprintf(stderr, "error: unable to open file"); 
    return 1; 
 cout << "file opened" << std::endl ;

 // Open a video file:
 cv::VideoCapture cap("C:/opencv/data/test.avi");
 if(!cap.isOpened()) {
     std::cout << "Unable to open the camera\n";

...... etc......

it reads the image and the binary file but not the video and I've tried any kind of video, also the same test.pgn image read by imread. I tried to debug but no errors, simply it does not load anything. The most annoying thing is that with the pre-built libraries 3.1.0 it runs even though in the compiler directory only but I can't use them because they don't support CUDA... Any clue? Thanks in advance.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by federocchi
close date 2016-06-17 04:44:12.946965


It was a building issue, as far as I can see a it's a very popular issue with opencv rel. 3.x.0, see: stackoverflow The videoio lib was probably built without ffmpeg due to a blank ffmpeg_version.cmake file while generating with CMake. It was misleading that the cmake configuration output reported FFMPEG: YES (prebuilt binaries) but I missed that all the other stuff like codec, format, etc where with NO instead of YES with version (i.e. ver 55.18.102).

federocchi gravatar imagefederocchi ( 2016-06-16 02:35:19 -0500 )edit