CameraX ImageAnalysis 设置的 TargetResolution 小于 640x480

CameraX ImageAnalysis set TargetResolution smaller than 640x480

我正在尝试通过将 480x360 图像提供给 CameraX 的 ImageAnalysis 来提高人脸检测率。但是,以下代码会生成 640x480 图像,从而将检测降低到 10 fps。如果我给 480x360 我可以提高 rate 到 20.

  1. 如何获得更小的目标分辨率和默认值

  2. 有没有把我做图像分析得到的图像作为prweview显示。与预览用例相反。这样人脸检测总体上不会和预览有很大的延迟。

    ImageAnalysis 图像分析 = 建设者 .setTargetResolution(新尺寸(360, 480)) .setTargetRotation(旋转) .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST) .build();

How can I get smaller target resolution and the defualt

docs 的默认值应为 640x480。

关于如何获得更小的目标分辨率,我可以想象出三种可能性。

  1. 您在某处错误地引用了 imageAnalysis 对象,它忽略了您的构建器,并默认为默认分辨率 640x480。
  2. 您的相机不支持 Size(360,480) 分辨率,最接近的支持分辨率是 640x480。
  3. 您以错误的顺序引用了尺寸,即尺寸 (360, 480) 可能导致选择的分辨率与尺寸 (480, 360) 不同。 (您在问题的两个顺序中都引用了它们)。

根据 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.

所以,我会尝试一些较小的尺寸,例如Size(200, 200) 并查看支持哪些更小的分辨率并从那里向上扩展。

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.

我不确定您为什么认为那样会更快,因为看起来这会序列化操作而不是同步执行它们。

如果您需要进一步的帮助,请提供您创建 ImageAnalysis 实例的所有代码。