Load RAW YUV video in OPENCV

两盒软妹~` 提交于 2019-12-10 23:24:25

问题


I have a problem with a RAW YUB video load in OpenCV. I can play it in mplayer with the following command:

mplayer myvideo.raw -rawvideo w=1280:h=1024:fps=30:y8 -demuxer rawvideo

My code for load in OpenCV is:

CvCapture* capture=cvCaptureFromFile("C:\\myvideo.raw");

cvCaptureFromFile always return NULL. But if I try with a normal avi file, the code runs normally (capture is not null).

I'm working with the lastest version of OpenCV under Windows 7.

EDIT: Output messages are

[IMGUTILS @ 0036f724] Picture size 0x0 is invalid  
[image2 @ 009f3300] Could not find codec parameters (Video: rawvideo, yuv420p)

Thanks


回答1:


OpenCV uses ffmpeg as back-end, however, it includes only a subset of ffmpeg functions. What you can try is to install some codecs. (K-lite helped me some time ago)

But, if your aim is to obtain raw YUV in OpenCV, the answer is "not possible".

OpenCV is hardcoded to convert every input format to BGR, so even if you will be able to open the raw input, it will automatically convery it to BGR before passing it. No chance to solve that, the only way is to use a different capture library or hack into OpenCV.

What you can do (to simulate YUV input) is to capture the avi, convert to YUV

cvtColor(...,CV_BGR2YCBCR /* or CV_BGR2YUV */ );

and then process it



来源:https://stackoverflow.com/questions/8164822/load-raw-yuv-video-in-opencv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!