CameraX ImageAnalysis set TargetResolution smaller than 640x480

人盡茶涼 提交于 2020-08-10 20:00:33

问题


I am trying to improve face detection rate by givining a 480x360 image to the ImageAnalysis of CameraX. However the following code produces 640x480 image, which reduces detection to 10 fps. If I give 480x360 I can improve rate to 20.

  1. How can I get smaller target resolution and the defualt

  2. Is there away to show the image I got for image anaysis as the prweview. As oppose to previews usecase. This is so that face detection overaly will not have big lag with the preview.

    ImageAnalysis imageAnalysis = builder .setTargetResolution(new Size(360, 480)) .setTargetRotation(rotation) .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST) .build();


回答1:


How can I get smaller target resolution and the defualt

The default as per the docs should be 640x480.

As to how to get smaller target resolutions, there are three possibilities I could imagine.

  1. You are incorrectly referencing the imageAnalysis object somewhere down the line and it is ignoring your builder one, and defaulting to the default resolution of 640x480.
  2. Your camera does not support a Size(360,480) resolution and the nearest supported one is 640x480.
  3. You are referencing the Size in the wrong order i.e. Size(360, 480) may result in a different selected resolution than Size(480, 360). (You reference them in both orders in your question).

As per the docs

The target resolution attempts to establish a minimum bound for the image resolution. The actual image resolution will be the closest available resolution in size that is not smaller than the target resolution, as determined by the Camera implementation. However, if no resolution exists that is equal to or larger than the target resolution, the nearest available resolution smaller than the target resolution will be chosen.

So, I'd try a few smaller sizes, e.g. Size(200, 200) and see what smaller resolutions are supported and scale up from there.

Is there a way to show the image I got for image anaysis as the prweview. As oppose to previews usecase. This is so that face detection overaly will not have big lag with the preview.

I'm not sure why you assume that would be faster, as it would seem this would serialize the operations rather than doing them synchronously.

If you want further help on this, please provide all your code surrounding the creation of your ImageAnalysis instance.



来源:https://stackoverflow.com/questions/63239815/camerax-imageanalysis-set-targetresolution-smaller-than-640x480

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!