如何在Visual C ++ 2010和2008中使用的OpenCV 2.1访问IP摄像机(康博IP50W) [英] how to access ip camera (compro IP50W) using OpenCV 2.1 in visual C++ 2010 or 2008

查看:237
本文介绍了如何在Visual C ++ 2010和2008中使用的OpenCV 2.1访问IP摄像机(康博IP50W)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  CvCapture *凸轮= cvCaptureFromFile(HTTP:\\\\ 192.168.0.77);
* IplImage的IMG;
IMG = cvQueryFrame(凸轮);* IplImage的电流= cvCreateImage(cvGetSize(IMG),IPL_DEPTH_8U,1);
*的IplImage = comResult cvCreateImage(cvGetSize(IMG),IPL_DEPTH_8U,1);双cam_w = cvGetCaptureProperty(凸轮,CV_CAP_PROP_FRAME_WIDTH);
双cam_h = cvGetCaptureProperty(凸轮,CV_CAP_PROP_FRAME_HEIGHT);
双FPS = 10;


解决方案

阅读<一href=\"http://opencv.willowgarage.com/documentation/reading_and_writing_images_and_video.html#capturefromfile\"相对=nofollow>文档:

  CvCapture * cvCaptureFromFile(为const char *文件名);


  

初​​始化捕获从文件。该功能cvCaptureFromFile(视频)分配并初始化CvCapture结构从指定的文件中读取视频流。其中codeCS和文件格式的支持依赖于后端库。


此功能从文件读取!你需要有一个摄像头连接到您的计算机可以从相机中检索帧。

然而后,如果您编译OpenCV的的ffmpeg 支持,你可以从网络中的文件读取,但您必须指定的文件名的在URL中。

在code注意下面的文件名结尾指定的:

  CvCapture *摄像头= cvCaptureFromFile(\"http://username:pass@cam_address/axis-cgi/mjpg/video.cgi?resolution=640x480&req_fps=30&.mjpg\");
如果(!摄像头)
{
    的printf(cvCaptureFromFile失败\\ n);
    出口(1);
}

必须测试OpenCV的函数的返回。你怎么能知道是否成功的功能,如果你不检查,对吧?!

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. 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.

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. How can you know if the function succeeded if you don't check it, right?!

这篇关于如何在Visual C ++ 2010和2008中使用的OpenCV 2.1访问IP摄像机(康博IP50W)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆