阅读背景:

opencv 网络摄像头(webcamera)

来源:互联网 

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



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: