opencv 网络摄像头(webcamera)

opencv 打开网络摄像头

代码如下:
#include 
#include 

#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://@/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;
		}
    }   
}


你可能感兴趣的:(opencv,人工智能,计算机视觉)