Android 相机意图图像质量
我正在制作一个 Android 应用程序,通过使用内置相机作为意图来使用相机。我正在逐像素地对照片进行一些分析。我的野火在正常照片中返回 79000 像素,这使得分析有点慢。
有没有办法设置使用意图时返回的相机或图像的质量/分辨率?我已经在 Google 和 api 上浏览过,但没有得到太多结果。有人知道这是否可能或知道其他降低图像分辨率的方法吗?
非常感谢任何帮助。
I'm making an android application that uses the camera by using the built in one as an intent. I'm doing some analysis on the photo on a pixel by pixel basis. My wildfire returns 79000 pixels in a normal photo, this is making the analysis a little slow.
Is there any way to set the quality/resolution of the camera or image returned when using intents? I've had a look around on Google and the api and haven't come up with much. Anyone know if this is even possible or know of some other way to degrade the image resolution?
Any help greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么要使用内置的应用程序,而不是使用 API 自己编写的应用程序?我在以这种方式使用相机时遇到了各种问题;毕竟,如果你想要完全控制,你不应该使用意图。有很多通过 API 拍照的工作示例。
因此,当通过 API 使用相机时,您可以使用 Camera 类的 setParameters 方法将 CameraParameters 对象传递给您的相机对象并更改各种参数。
CameraParameters 类包含一个 setPictureSize(int , int) 方法,该方法您可以使用它来更改图片的大小。您可以使用 CameraParameters 的 getSupportedPictureSizes() 方法来了解您的设备支持哪些图片尺寸并使用适合您的尺寸。
另外,我发现您可以将图片格式设置为NV21。这是一种原始格式,您可以轻松地自行对返回图像的像素进行二次采样(将单个像素作为每 4 个像素的平均值,这样您就可以将图像宽度和高度减少两倍)!
Why use the built in Appliction though the intent and not an application you'll write yourself by using the API ? I have seen various problems when using the camera this way; after all, if you want full control you shouldn't be using the intent. There are lots of working examples for taking photos through the API.
So, when using the camera through the API you may use the setParameters method of the Camera class to pass a CameraParameters object to your camera object and change various parameters.
The CameraParameters class contains a setPictureSize(int , int) method which you may use to change the size of your picture. You can use the getSupportedPictureSizes() method of CameraParameters to find out which picture sizes your device supports and use the one that fits you.
Also, I see that you may set the format of your picture as NV21. This is a raw format and you can easily subsample the pixels of the returned image yourself (take a single pixel as the average of every 4 pixels so you will reduce both your image width and height by two) !