C++ code Capturing image from IP / Ethernet Cameras (AXIS Cam)

时光怂恿深爱的人放手 提交于 2019-12-01 10:54:31
int main()
{
    Mat frame;
    namedWindow("video", 1);
    VideoCapture cap("http://150.214.93.55/mjpg/video.mjpg");
    while ( cap.isOpened() )
    {
        cap >> frame;
        if(frame.empty()) break;

        imshow("video", frame);
        if(waitKey(30) >= 0) break;
    }   
    return 0;
}

no idea, how your urls look like, but opencv seems to insist, it has to end with mjpg. so if it doesn't, the trick is to append a dummy parameter:

http://my/cool/ip-cam.ie?dummy=video.mjpg

if you need to open all 4 cams at once, you need a VideoCapture for each one:

VideoCapture cap1("url1");
VideoCapture cap2("url2");
VideoCapture cap3("url3");
VideoCapture cap4("url4");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!