Decrease image resolution in OpenCV

后端 未结 1 1069
长情又很酷
长情又很酷 2021-01-07 04:55

I\'m using OpenCV to capture images from A4Tech camera. When I try to decrease image resolution, image assertion fails:

CvCapture *camera = cvCreateCameraCap         


        
相关标签:
1条回答
  • 2021-01-07 05:26

    You seem to be doing it the right way, but OpenCV is known to have issues doing this kind of stuff. Are you sure your camera supports 160x140? Cheese says my camera supports 160x120, but when I select this format nothing seems to change.

    One thing though, it's best to always check the return of OpenCV calls, for instance:

    CvCapture *camera = cvCreateCameraCapture(1);
    if (!camera)
    {
        // print error and exit
    }
    

    One thing you could do is resize the captured frame to the resolution you want. It's not ideal, I know, your CPU is going to do this task and therefore there will be some performance cost to your application, but if you need the image to be of a certain size and OpenCV is not playing nice there ain't much you can do, unless you are willing to make a surgery on OpenCV.

    EDIT:

    One thing you should do is check whether these values were really set. So after setting them, retrieve them with cvGetCaptureProperty().

    0 讨论(0)
提交回复
热议问题