我買了OpenCV書籍,第一個視頻程序無法正常工作。在繼續之前,我想知道我的系統中是否有問題。這是一個非常簡單的程序,很少需要調試。'Hello world'video program not working
#include "highgui.h"
int main(int argc, char** argv) {
cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE);
CvCapture* capture = cvCreateFileCapture(argv[1]);
IplImage* frame;
while(1) {
frame = cvQueryFrame(capture);
if(!frame) break;
cvShowImage("Example2", frame);
char c = cvWaitKey(33);
if(c == 27) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("Example2");
}
它編譯通常,但運行時,程序只是打開一個白色的窗口幾秒鐘,然後關閉。顯然,沒有任何錯誤,看起來像是一個貶低警告。什麼可能是錯的?
k♥t ./demo /opt/Media/Vídeos/Docs/Connections/Connections/02\ -\ Death\ in\ the\ Morning.avi
Using network protocols without global network initialization. Please use avformat_network_init(), this will become mandatory later.
k♥t
編輯:對不起,所有的大驚小怪,這只是一個錯字。現在修好了。
您使用的是什麼版本的OpenCV?什麼OS?什麼IDE /構建環境? – mevatron