1
嗨我試圖讓這個代碼運行,但它給我分段錯誤。我想在本地保存4秒鐘的IP攝像頭供稿,以作進一步處理。我似乎無法訪問直接Feed,因此我必須採用間接方式。從JPG製作avi文件opencv
#include "cv.h"
#include "highgui.h"
#include<iostream>
using namespace std;
int main()
{
IplImage *img;
CvSize size;
img = cvLoadImage(" http://192.168.1.4:1024/shot.jpg");
size.width=img->width;
size.height = img->height;
CvVideoWriter *writer = cvCreateVideoWriter(
"out.avi",
CV_FOURCC('P','I','M','1') ,
30,
size,
TRUE
);
if(writer ==NULL)
{
cout<<"No videowrite here !!!!"<<endl;
}
while(img!= NULL)
{
img = cvLoadImage("http://local_ip:1024/shot.jpg");
cvWriteFrame(writer,img);
}
cvReleaseVideoWriter(&writer);
cvReleaseImage(&img);
return 0;
}
也許你應該在'img = cvLoadImage(「http:// local_ip:1024/shot.jpg」)後檢查'if(img!= NULL)';'in cycle '而(IMG!= NULL)' – borisbn 2013-03-09 20:29:27