简体   繁体   中英

Take high resolution image from ip camera using opencv

I have an ip camera. It allows me to have two different encoding type, h264 and mjpeg and its best resolution is 1920x1080.

I use iSpy software to find URL address of my camera. It works and take photo, but its resulotion is 640*360.

Here is my code:

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/opencv.hpp"

int main()
{
    cv::VideoCapture vcap;

    const std::string videoStreamAddress = "rtsp://admin:admin@192.168.0.120/snl/live/1/2/stream1.cgi";

    if (!vcap.open(videoStreamAddress))
    {
        printf("camera is null\n");
        return -1;
    }
    else
    {
        vcap.set(CV_CAP_PROP_FRAME_WIDTH, 1920);
        vcap.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);

        cv::Mat image;
        vcap.read(image);
        cv::imshow("image",image);
        cv::imwrite("image.jpg", image);
    }

    cv::waitKey(1000);
    return 0;
 }

How can I take image with higher quality. I don't know the problem is from my camera, or my url, or my code.

I work with opencv 2.4 on windows 7.

Any help would be appreciated

I'm answering my own question.

At first I'd thought the problem is rooted in OpenCV, since I'd found many threads about setting camera parameters failures. It seems that vcap.set(CV_CAP_PROP_FRAME_WIDTH, 1920);vcap.set(CV_CAP_PROP_FRAME_HEIGHT, 1080); doesn't work well.

Anyway, I've checked my camera Development Document on its website and found another URL for H.264 video stream. I've changed my URL, and it works. It takes 1920X1080 images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM