嗨,我正在尝试运行此代码,但它给了我分段错误。我想在本地保存 4 秒的 IP 摄像头供稿作为 avi 文件以供进一步处理。我似乎无法访问直接提要,所以我必须采用间接方式。
#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;
}