私は涙のような感情表現を分析するプログラムを書こうとしています。私のトラッカーの一環として、私は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;
}
どのプラットフォーム/ OSですか? –
質問を編集して、SIGABRTの後にコンソール/端末に表示されるエラーメッセージを含めることができますか?これはエラーの詳細を理解するのに役立ちます。 – speciousfool