我使用openCV 2.3.1連接到IP攝像機。如何使用OpenCV 2.3.1連接到IP Camera?
這裏是我的代碼
#include "../../../OpenCV/include/opencv/cv.h"
#include "../../../OpenCV/include/opencv/highgui.h"
CvCapture *camera = cvCreateFileCapture("http://usr:[email protected]:port/nphMotionJpeg?resolution=320x240&Quality=Standard");
if (camera == NULL)
printf("camera is null\n");
else
printf("camera is not null");
cvNamedWindow("img");
int d = cvWaitKey(10);
while (d != atoi("q"))
{
d = cvWaitKey(10);
double t1 = (double)cvGetTickCount();
IplImage *img = cvQueryFrame(camera);
double t2=(double)cvGetTickCount();
printf("time: %gms fps: %.2g\n",(t2-t1)/(cvGetTickFrequency()*1000.), 1000./((t2-t1)/(cvGetTickFrequency()*1000.)));
cvShowImage("img",img);
}
cvReleaseCapture(&camera);
但上述cvCreateFileCapture()函數總是返回null,但如果我使用cvCreateFileCapture( 「video.avi」)是確定的,請向我解釋爲什麼?
我已經在stackoverflow.com上看過關於這個問題的很多線程,但我沒有任何方法可以解決這個問題。我使用的是OpenFV 2.3.1,我已經用ffmpeg構建了它(我不確定這一點,但是在構建它之後,我的文件夾中有opencv_ffmpeg.dll)。
它看起來像'cvCreateFileCapture'只支持本地文件。 – 2012-02-08 01:55:48