简体   繁体   English

如何解决android.hardware.camera返回的不同预览/图片大小?

[英]How to solve different Preview/Picture sizes returned by android.hardware.camera?

So I've been playing with the android camera library and using it in a surfaceview. 因此,我一直在使用android相机库并在Surfaceview中使用它。 I have found that there's no way to capture pictures that match preview. 我发现无法捕获与预览匹配的图片。 In fact, one has to always check the preview and picture sizes and set the camera parameters to get the best match possible. 实际上,必须始终检查预览和图片大小,并设置相机参数以获得最佳匹配。 Also, you can't just set the camera to have the same sizes for both since the app will crash if the camera doesn't support them. 另外,您不能仅将相机的尺寸设置为相同,因为如果相机不支持相机,应用程序将崩溃。

How can this be? 怎么会这样? Is there really no other solution? 真的没有其他解决方案吗? I mean Instagram seems to use it (it doesn't launch the phone's camera app) and there always seems to be a perfect match. 我的意思是,Instagram似乎正在使用它(它不会启动手机的相机应用程序),而且似乎总是很合适。

Any ideas? 有任何想法吗? Thanks! 谢谢!

Simplest, and largely practical, approach is treat the preview as a mere feedback mechanism and to concentrate the program logic on getting the best - and desired - quality of image capture. 最简单且广泛实用的方法是将预览视为一种单纯的反馈机制,并将程序逻辑集中在获得最佳(和期望的)图像捕获质量上。

There is little novelty in mixing the two together. 将两者混合在一起几乎没有什么新奇之处。

Also, the desired image capture quality may depend on different factors/options. 同样,所需的图像捕获质量可能取决于不同的因素/选项。 Based on post capture processing times, storage constraints, upload constraints, and more; 基于后期捕获处理时间,存储限制,上传限制等; the best quality image may not be the always desired one. 最佳质量的图像可能不是始终想要的。

Implementation wise, the camera apps follow some common practices as below: 在实施方面,相机应用程序遵循以下一些常见做法:

  1. Use Camera.getParameters().getSupportedPictureSizes() to get the complete list. 使用Camera.getParameters()。getSupportedPictureSizes()获取完整列表。
  2. Decide the best fit depending upon the constraints. 根据约束条件确定最佳拟合。
  3. Some apps implement device specific best fit logic. 一些应用程序实现特定于设备的最佳匹配逻辑。 Mostly, the popular devices get targeted. 通常,流行的设备会成为目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查android.hardware.Camera是否已发布? - How to check if android.hardware.Camera is released? 尝试使用Android.Hardware.Camera拍照时出错 - Error trying to take picture with Android.Hardware.Camera android.hardware.camera预览:如何手动设置曝光时间,快门速度,光圈和ISO - android.hardware.camera preview : How to manually set exposure time, shutter speed, aperture, and iso Android 相机 android.hardware.Camera 已弃用 - Android camera android.hardware.Camera deprecated android.hardware.Camera $ EventHandler.handleMessage - android.hardware.Camera$EventHandler.handleMessage 以横向模式返回(android.hardware.Camera) - Returning (android.hardware.Camera) in landscape mode Android上不同尺寸的相机预览 - Different sizes of camera preview on Android android.hardware.Camera 是否适用于较新版本的 android? - Does android.hardware.Camera work for newer versions of android? 如何使用API​​编译项目/参考AppCompat库以使用android.hardware.Camera? - How to Compile project against API 19/Reference the AppCompat library in order to use android.hardware.Camera? android.hardware.Camera是否仍可在所有API级别上使用? - Does android.hardware.Camera still works on all API levels?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM