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 = "https://<username:password>@<ip_address>/video.cgi?.mjpg";
const std::string videoStreamAddress = "rtsp://admin:[email protected]/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;
}
}
}#include <s