C++ 如何使用OpenCV 2.3.1连接到IP摄像头?
我正在使用openCV 2.3.1连接到IP摄像头 这是我的密码C++ 如何使用OpenCV 2.3.1连接到IP摄像头?,c++,C++,我正在使用openCV 2.3.1连接到IP摄像头 这是我的密码 #include "../../../OpenCV/include/opencv/cv.h" #include "../../../OpenCV/include/opencv/highgui.h" CvCapture *camera = cvCreateFileCapture("http://usr:pass@ip:port/nphMotionJpeg?resolution=320x240&Quality=Standar
#include "../../../OpenCV/include/opencv/cv.h"
#include "../../../OpenCV/include/opencv/highgui.h"
CvCapture *camera = cvCreateFileCapture("http://usr:pass@ip: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上读过很多关于这个问题的帖子,但是我还没有办法解决这个问题
我使用的是OpenCV 2.3.1,我用ffmpeg构建了它(我不确定这一点,但构建后我的文件夹中有OpenCV_ffmpeg.dll)。因为,您只能将本地文件的路径传递给cvCreateFileCapture()
如果要在IP摄像头上使用openCV,则必须通过另一种方式从服务器获取图像,然后使用openCV单独分析帧。尝试使用LibIpCurl。它支持连接到Ip摄像头。它看起来像
cvCreateFileCapture
只支持本地文件。真的吗?我没有看到文件提到本地文件。我读过很多文章,有一些人成功地使用了这段代码。但如果是真的,你能告诉我连接IP摄像头的其他方法吗?非常感谢:)