失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 利用OpenCV读取大华网络摄像头

利用OpenCV读取大华网络摄像头

时间:2018-11-05 23:56:24

相关推荐

利用OpenCV读取大华网络摄像头

项目需要将网络摄像头接入到服务器上,用c++或者python处理每帧的图像。查了很多资料总算解决了,回过头发现是很小的问题,但是大华官网的SDK真的很难看懂。OpenCV2.4。

直接上代码吧。

#include "cv.h"#include "highgui.h"#include <stdio.h>using namespace std;using namespace cv;int main(int, char**) {VideoCapture vcap;Mat image;const string videoStreamAddress = "rtsp://admin:dahua@192.168.1.108/cam/realmonitor?channel=1&subtype=0";/* it may be an address of an mjpeg stream,e.g. "http://user:pass@cam_address:8081/cgi/mjpg/mjpg.cgi?.mjpg" *///open the video stream and make sure it's openedif(!vcap.open(videoStreamAddress)) {cout << "Error opening video stream or file" << endl;return -1;}else{cout<<"success"<<endl;}//Create output window for displaying frames.//It's important to create this window outside of the `for` loop//Otherwise this window will be created automatically each time you call//`imshow(...)`, which is very inefficient.namedWindow("Output Window");for(;;) {if(!vcap.read(image)) {cout << "No frame" << endl;waitKey();}imshow("Output Window", image);if(waitKey(1) >= 0) break;}}

大华的网络摄像头编号:DH-IPC-HFW1225M-I1-0600B,用的是RTSP协议。

“rtsp://admin:dahua@192.168.1.108/cam/realmonitor?channel=1&subtype=0”;

其中的admin,dahua是登录摄像头的用户名和密码。IP地址是192.168.1.108,可以根据具体情况修改。

如果觉得《利用OpenCV读取大华网络摄像头》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。