Ask Your Question

Ganesh K's profile - activity

2018-05-01 17:00:25 -0600 received badge  Popular Question (source)
2016-07-09 14:31:53 -0600 received badge  Editor (source)
2016-07-09 14:27:01 -0600 asked a question YUV video file reading problem because of codec problem

Hi.

I am reading YUV video file. I am using the code below. I got the error as Picture size 0x0 is invalid. Warning: Could not find codec parameters <../../modules/highgui/src/cap_ffmpeg_impl.hpp:548>

// VideoExample1.cpp : This file reads the video from file and displays it in the window //

include "stdafx.h"

include <opencv2 core.hpp="">

include <opencv2 imgcodecs.hpp="">

include <opencv2 highgui.hpp="">

include <opencv2 imgproc="" imgproc.hpp="">

include <iostream>

using namespace cv; using namespace std;

int main(int argc, char* argv[]) { VideoCapture cap("C:/videos/a.yuv"); // open the video file for reading

if ( !cap.isOpened() )  // if not success, exit program
{
     cout << "Cannot open the video file" << endl;
     return -1;
}

//cap.set(CV_CAP_PROP_POS_MSEC, 300); //start the video at 300ms

double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video

 cout << "Frame per seconds : " << fps << endl;

namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

while(1)
{
    Mat frame;

    bool bSuccess = cap.read(frame); // read a new frame from video

    if (!bSuccess) //if not success, break loop
    {
                    cout << "Cannot read the frame from video file" << endl;
                   break;
    }

    imshow("MyVideo", frame); //show the frame in "MyVideo" window

    if(waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
   {
            cout << "esc key is pressed by user" << endl; 
            break; 
   }
}

return 0;

}

image description

2016-07-01 01:09:29 -0600 asked a question yuv420 to rgb

How to convert YUV420 to RGB in OpenCV?