Search code examples
visual-c++opencvip-camera

IP camera video streaming using openCV in VC++


I have never written VC++ apps and now i am assigned a task of capturing IP camera and saving as files on the harddisk.

i was surfing for last 2 days but cant find any suitable link or code for the same.

the sample code i found on the net, captures webcam but nothing relevent to reading video streams on rtsp protocols with credentials.

please help me for this.. Thanks & Regards


Solution

  • The below is the code snippet which accesses a public ip camera, which works fine for me.

    int main(int argc, char *argv[])
    {
        Mat frame;
        namedWindow("video", 1);
        VideoCapture cap("http://66.184.211.231/mjpg/video.mjpg");
        while ( cap.isOpened() )
        {
            cap >> frame;
            if(frame.empty()) break;
    
            imshow("video", frame);
            if(waitKey(30) >= 0) break;
        }
    
        return 0;
    }
    

    And here are few link for your reference link1 link 2