[問題] Opencv 寫影片的問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC2010
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
OPCV
問題(Question):
cvVideoWriter 無法正常初始化
餵入的資料(Input):
cvCreateVideoWriter("out.avi",CV_FOURCC('X','I','V','D'),fps,
cvSize(frameW,frameH),isColor);
預期的正確結果(Expected Output):
正常初始化後輸出影片。
錯誤結果(Wrong Output):
molloc 無法正常配置記憶體
程式碼(Code):(請善用置底文網頁, 記得排版)
// Opencv.camala.test.cpp : 定義主控台應用程式的進入點。
#include "stdafx.h"
#include <stdio.h>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
typedef struct CvVideoWriter CvVideoWriter;
int main( int argc, char** argv ) {
IplImage* pFrame = NULL;
CvCapture* pCapture = NULL;
int isColor = 1;
int fps = 25; // or 30
int frameW = 744; // 744 for firewire cameras
int frameH = 480; // 480 for firewire cameras
CvVideoWriter *writer = cvCreateVideoWriter("out.avi",
CV_FOURCC('X','I','V','D'),fps,cvSize(frameW,frameH),isColor);
//將上一行丟進去編譯會直接當機,感覺是記憶體的問題。
//下面就不是很重要了
cvNamedWindow("video", 1);
pCapture = cvCaptureFromCAM(-1);
while(pFrame = cvQueryFrame( pCapture )) {
cvShowImage("video", pFrame);
if(cvWaitKey(2) >= 0 ){
if(!cvGrabFrame(pCapture)){
printf("Could not grab a frame\n");
}
cvSaveImage("test.jpg",pFrame);
break;
}
}
cvDestroyWindow("video");
cvReleaseCapture(&pCapture);
cvReleaseVideoWriter(&writer);
return 0;
}
補充說明(Supplement):
有照官方網站的視頻讀寫概述,安裝XVID後依舊出現錯誤。
拜託各位大大幫忙看一下錯在哪。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.248.204.99
推
03/27 00:01, , 1F
03/27 00:01, 1F
→
03/27 00:16, , 2F
03/27 00:16, 2F
→
03/27 01:19, , 3F
03/27 01:19, 3F
→
03/27 01:20, , 4F
03/27 01:20, 4F
推
03/27 02:10, , 5F
03/27 02:10, 5F
→
03/27 02:59, , 6F
03/27 02:59, 6F
推
03/27 06:59, , 7F
03/27 06:59, 7F
→
03/27 06:59, , 8F
03/27 06:59, 8F
推
03/27 18:48, , 9F
03/27 18:48, 9F