您的位置:首页 > 运维架构

citytech摄像头 opencv+rtsp获得图像

2016-05-03 14:41 260 查看
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
int main(int argc, char **argv) {

    using namespace std;
    IplImage *pFrame = NULL, *srcImage = NULL;

    CvCapture *pCapture = NULL;
    pCapture = cvCreateFileCapture("rtsp://192.168.1.10:554/user=admin&password=admin&channel=1&stream=1.sdp?real_stream");
 
    if (!pCapture) {
        printf("Can not get the video stream from the camera!\n");
        return NULL;
    }

    
    while (1) {
        if (srcImage == NULL)
        {
            pFrame = cvQueryFrame(pCapture);
            srcImage = cvCloneImage(pFrame);
            cvCircle(srcImage,cvPoint(pFrame->width/2, pFrame->height/2),5, CV_RGB(255, 0, 0),1,8,0);   // 在视频中心处画圆
            cvShowImage("123234", srcImage);
            cout<<pFrame->width<<","<<pFrame->height<<endl;

            cvWaitKey(10);
            cvReleaseImage(&srcImage);
            srcImage = NULL;
        }

    }
    cvReleaseCapture(&pCapture);
    cvReleaseImage(&pFrame);

    return 0;
}

citytech摄像头的rtsp地址格式

rtsp://$(IP):$(PORT)/user=$(USER)&password=$(PWD)&channel=$(Channel)&stream=$(Stream).sdp?real_stream

例如账号admin 密码admin stream是主视频流(主0 辅1)

类似rtsp://10.6.10.25:554/user=admin&password=admin&channel=1&stream=0.sdp?real_stream 如果是通过公网需要将RTSP端口开放(

默认是554),这个端口在网络服务->RTSP中可以设置。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: