首页 > 解决方案 > tensorflow lite 示例对象检测中相机的屏幕尺寸

问题描述

在 tensorflow lite 示例对象检测中,相机不会占用所有屏幕,而只是占用一部分。

我试图在 CameraActivity、CameraConnectionFragment 和 Size 类中找到一些常量,但没有结果。

所以我只是想要一种将相机放在整个屏幕上的方法,或者只是一个解释。

谢谢。

标签: tensorflowcamerasizetensorflow-lite

解决方案


我刚刚找到了解决方案,它在 CameraConnectionFragment 类中: protected static Size chooseOptimalSize(final Size[] options, final int width, final int height) { final int minSize = Math.max(Math.min(width, height), MINIMUM_PREVIEW_SIZE ); 最终尺寸所需尺寸 = 新尺寸(1280, 720);

protected static Size chooseOptimalSize(final Size[] choices, final int width, final int height) {
final int minSize = Math.max(Math.min(width, height), MINIMUM_PREVIEW_SIZE);
final Size desiredSize = new Size(1280, 720);

// Collect the supported resolutions that are at least as big as the preview Surface
boolean exactSizeFound = false;
final List<Size> bigEnough = new ArrayList<Size>();
final List<Size> tooSmall = new ArrayList<Size>();
for (final Size option : choices) {
  if (option.equals(desiredSize)) {
    // Set the size but don't return yet so that remaining sizes will still be logged.
    exactSizeFound = true;
  }

  if (option.getHeight() >= minSize && option.getWidth() >= minSize) {
    bigEnough.add(option);
  } else {
    tooSmall.add(option);
  }
}

只需将 1280、720 替换为我们想要的即可。


推荐阅读