How to set camera resolution in Android with OpenCV?

前端 未结 3 803
被撕碎了的回忆
被撕碎了的回忆 2020-12-28 20:51

I\'m trying to develop an app for Android, and I would need to get uncompressed pictures with a resolution as high as possible from the camera. I tried takePicture\'s rawCal

相关标签:
3条回答
  • 2020-12-28 21:36

    setPreviewSize does not set picture resolution. setPictureSize does.

    0 讨论(0)
  • 2020-12-28 21:37

    In case anybody ever finds this useful, I found a (partial) solution: If your VideoCapture variable is called vc, this should work:

    vc.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, desiredFrameWidth);
    vc.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, desiredFrameHeight);
    

    Mind that the combination of width and height must be one of the supported picture formats for your camera, otherwise it will just get a black image. You can get those through Camera.Parameters.getSupportedPictureSizes().

    However, setting a high resolution appears to exceed the YUV conversion buffer's capacity, so I'm still struggling with that. I'm going to make a new separate question for that, to keep everything clearer: new thread

    0 讨论(0)
  • 2020-12-28 21:41

    You have to get supported camera preview resoultions by calling getSupportedPreviewSizes.

    After this you can set any resolution with method setPreviewSize. And don't forget to setParameters in the end. Actally many OpenCV Android examples contain this information (look at sample3).

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