我想写一个程序来分析眼泪等情绪表达。作为我的跟踪器的一部分,我使用OpenCV来录制示例视频。特别是,我不确定如何正确选择FPS(10FPS似乎应该工作)。我也不能肯定这 编解码器,我应该在OS X上使用,我已经尝试了从here所有可能CV_FOURCC很好,但返回以下错误:如何用OpenCV编写视频文件?
Stream #0.0: Video: rawvideo, yuv420p, 640x480, q=2-31, 19660 kb/s, 90k tbn, 10 tbc
Assertion failed: (image->imageSize == avpicture_get_size((PixelFormat)input_pix_fmt, image->width, image->height)), function writeFrame, file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_opencv/work/OpenCV-2.2.0/modules/highgui/src/cap_ffmpeg.cpp, line 1085.
你都与cvWriteFrame一些工作代码?感谢您花时间看我的问题!
对于那些有兴趣的整个程序是:
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
int main (int argc, const char * argv[])
{
CvCapture *capture;
IplImage *img;
int key = 0;
CvVideoWriter *writer;
// initialize camera
capture = cvCaptureFromCAM(0);
// capture = cvCaptureFromAVI("AVIFile");
// always check
assert(capture);
// create a window
cvNamedWindow("video", 1);
int color = 1; // 0 for black and white
// get the frame size
CvSize size = cvSize((int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT));
writer = cvCreateVideoWriter(argv[1], -1 , 10 , size, color);
while(key != 'q') {
// get a frame
img = cvQueryFrame(capture);
// always check
if(!img) break;
cvWriteFrame(writer, img);
cvShowImage("video", img);
// quit if user press 'q'
key = cvWaitKey(5);
}
// free memory
cvReleaseVideoWriter(&writer);
cvReleaseCapture(&capture);
cvDestroyWindow("video");
return 0;
}
什么平台/操作系统? – 2011-02-02 08:59:53
您是否可以在SIGABRT之后编辑问题以包含打印在控制台/终端中的错误消息?这将帮助我们更多地了解错误。 – speciousfool 2011-02-02 23:46:10