您的位置:首页 > 理论基础 > 计算机网络

opencv 网络摄像头(webcamera)

2016-03-09 18:19 507 查看

opencv 打开网络摄像头

代码如下:
#include <stdio.h>
#include <iostream>

#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/highgui/highgui.hpp"

int main(int, char**) {
cv::VideoCapture vcap;
cv::Mat image;

// This works on a D-Link CDS-932L
//const std::string videoStreamAddress = "http://<username:password>@<ip_address>/video.cgi?.mjpg";
const std::string videoStreamAddress = "rtsp://admin:User1234@192.168.1.236/h264/ch1/main/av_stream";
//open the video stream and make sure it's opened
if(!vcap.open(videoStreamAddress)) {
std::cout << "Error opening video stream or file" << std::endl;
return -1;
}

for(;;) {
if(!vcap.read(image)) {
std::cout << "No frame" << std::endl;
cv::waitKey();
}
cv::imshow("Output Window", image);
if(cv::waitKey(1) >= 0) {
break;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息