在tensorflow lite示例对象检测中,相机不会拍摄整个屏幕,而只会拍摄一部分。
我试图在 CameraActivity、CameraConnectionFragment 和 Size 类中找到一些常量,但没有结果。
所以我只是想要一种将相机放在整个屏幕中的方法,或者只是一个解释。
谢谢你。
最佳答案
我刚刚找到解决方案,它在 CameraConnectionFragment 类中: protected static Size ChooseOptimalSize(final Size[] Choices, Final int width, Final int height) { 最终 int minSize = Math.max(Math.min(宽度, 高度), MINIMUM_PREVIEW_SIZE); 最终大小desiredSize = new 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 替换为我们想要的即可。
关于tensorflow - Tensorflow lite 对象检测示例中相机的屏幕尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57242648/