[問題] Opencv 寫影片的問題

看板C_and_CPP作者 (肉包)時間14年前 (2011/03/26 22:40), 編輯推噓4(405)
留言9則, 5人參與, 最新討論串1/1
開發平台(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
有'X','I','V','D'這種東西嗎..?
03/27 00:01, 1F

03/27 00:16, , 2F
抱歉打錯,('D', 'I', 'V', 'X') 但是依舊當機。
03/27 00:16, 2F

03/27 01:19, , 3F
XVID試試看會不會當機吧
03/27 01:19, 3F

03/27 01:20, , 4F
opencv應該是要有ffmpeg才能用這些codec吧
03/27 01:20, 4F

03/27 02:10, , 5F
先試試看-1有沒有跳出選項
03/27 02:10, 5F

03/27 02:59, , 6F
-1也是當機,ffmpeg是什麼意思?
03/27 02:59, 6F

03/27 06:59, , 8F
不知道昨日的這篇有沒有幫助?
03/27 06:59, 8F

03/27 18:48, , 9F
我用svn版opencv還滿正常的
03/27 18:48, 9F
文章代碼(AID): #1DZVhM_x (C_and_CPP)