[英]how to access ip camera (compro IP50W) using OpenCV 2.1 in visual C++ 2010 or 2008
CvCapture* cam = cvCaptureFromFile("http:\\192.168.0.77");
IplImage* img;
img = cvQueryFrame(cam);
IplImage* current = cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,1);
IplImage* comResult = cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,1);
double cam_w = cvGetCaptureProperty(cam, CV_CAP_PROP_FRAME_WIDTH);
double cam_h = cvGetCaptureProperty(cam, CV_CAP_PROP_FRAME_HEIGHT);
double fps = 10;
Read the documentation : 阅读文档 :
CvCapture* cvCaptureFromFile(const char* filename);
Initializes capturing a video from a file.The function cvCaptureFromFile() allocates and initializes the CvCapture structure for reading the video stream from the specified file.
初始化从文件中捕获视频。函数cvCaptureFromFile()分配并初始化CvCapture结构,以从指定文件中读取视频流。 Which codecs and file formats are supported depends on the back end library.
支持哪种编解码器和文件格式取决于后端库。
This functions reads from a file ! 此功能从文件读取! You need to have a camera connected to your computer to be able to retrieve frames from the camera.
您需要将相机连接到计算机才能从相机中检索帧。
However , if you compiled OpenCV with ffmpeg support you can read from a file in the network, but you must specify the filename in the url. 但是 ,如果使用ffmpeg支持编译了OpenCV,则可以从网络中的文件中读取内容,但是必须在url中指定文件名 。
Notice in the code below that the filename is specified at the end: 注意下面的代码中,文件名是在末尾指定的:
CvCapture* camera = cvCaptureFromFile("http://username:pass@cam_address/axis-cgi/mjpg/video.cgi?resolution=640x480&req_fps=30&.mjpg");
if (!camera)
{
printf("cvCaptureFromFile failed\n");
exit(1);
}
Always test the return of OpenCV functions. 始终测试OpenCV函数的返回。 How can you know if the function succeeded if you don't check it, right?!
不检查就知道函数是否成功,对吗?
I found this site helpful to solve this problem 我发现此站点有助于解决此问题
It purpose a simple way to solve the problem regarding handling FFMPEG decode in opencv C++ (windows) and now I am able to retrieve image from IP camera using highgui 它旨在提供一种简单的方法来解决有关在opencv C ++(Windows)中处理FFMPEG解码的问题,现在我能够使用highgui从IP摄像机检索图像
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.