Ask Your Question

Revision history [back]

How do I control the PTZ function of IP camera using C++

I am working on a project that requires the control of the PTZ function of my IP camera through the UI. I am currently using a D-Link DCS-5020L cloud camera, Microsoft Visual Studio 2017 and OpenCV 3.3 for my setup.

I am still new to C++ OpenCV but my project requires the use of it. I am able to access the camera feed but I'm not sure how to control the functions of the camera using C++ code through OpenCV or if OpenCV is even needed.

Is there a C++ code to control the PTZ functions of the IP camera?

This is my code for attaining the video output, if necessary.

// VIDEO CAPTURE //

Mat frame;

VideoCapture cap("http://username:password@IPADDRESS:PORT/video.cgi?resolution=640x360&req_fps=30&.mjpg");

if (!cap.isOpened())    //EXIT PROGRAM IF FAILED
{
    cout << "CAMERA UNAVAILABLE" << endl;
    return -1;
}
while (1)
{
    bool bSuccess = cap.read(frame);    //READ NEW FRAME FROM VIDEO

    if (!bSuccess)      //BREAK LOOP IF FAILED
    {
        cout << "UNABLE TO DISPLAY VIDEO" << endl;
        break;
    }
}

Any help is appreciated. Thank you.