reading a video with opencv
Hi! I have a video engine2.avi that I want to read and show with openCV. here 's the code that I used:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
int main(int argc, char** argv)
{
string filename = "D:\\BMDvideos\\engine2.avi";
VideoCapture capture(filename);
Mat frame;
if( !capture.isOpened() )
throw "Error when reading steam_avi";
namedWindow( "w", 1);
for( ; ; )
{
capture >> frame;
// if(!frame)
// break;
imshow("w", frame);
waitKey(20); // waits to display frame
}
waitKey(0); }
this code doesn't work if I the file has the codec YUV 4:2:2 (UYVY)(I record the video using Direct-Show), but works when I use a video that grabbed whit openCV !! has anybody an Idea how this could work ? thanks in advance