我想寫一個程序來分析眼淚等情緒表達。作爲我的跟蹤器的一部分,我使用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