Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supported camera preview sizes for popular Android handsets

Tags:

android

camera

I'm working with camera preview frames, and need to make a decision about what minimum preview size I will work with. I need fairly high resolution, and am trying to figure out the highest preview resolution I can get across the more popular Android handsets and OS versions. (Judging by this question about Nexus One / Froyo preview sizes, it looks like they sometimes change across OS versions for the same device.)

Is there a resource anywhere that basically lists the output of android.hardware.Camera.Parameters.getSupportedPreviewSizes() for lots of different devices (or device/OS version pairs)?

Alternatively, if there is no such listing, this question could become such a resource. I will very happily upvote any answers that include new individual data points for specific handsets / OS versions.

And to forestall the obvious comment: Yes, I know I will need to test my code on lots of devices anyway. But ideally I would like to make some reasonably informed decisions about resolution early on, without having to purchase a bevy of devices just to get started.

like image 861
Josh Bleecher Snyder Avatar asked Dec 20 '10 01:12

Josh Bleecher Snyder


People also ask

What is camera preview in Android?

PreviewView is a subclass of FrameLayout . To display the camera feed, it uses either a SurfaceView or TextureView , provides a preview surface to the camera when it's ready, tries to keep it valid as long as the camera is using it, and when released prematurely, provides a new surface if the camera is still in use.

How do I change the camera size on my Android?

If you want to set a specific size for your camera preview, set this in the surfaceChanged() method as noted in the comments above. When setting preview size, you must use values from getSupportedPreviewSizes(). Do not set arbitrary values in the setPreviewSize() method.

What is preview in camera?

The image is cropped to the aspect ratio of the camera preview, then scaled to fill the preview (field of view is reduced): On foldable devices, the orientation of the camera sensor can be portrait while the aspect ratio of the display is landscape: Figure 10.

How do I change camera preview orientation on Android?

To force portrait orientation: set android:screenOrientation="portrait" in your AndroidManifest. xml and call camera. setDisplayOrientation(90); before calling camera.


1 Answers

My experience tells me, that 640x480 is available almost everywhere, and even if bigger resolutions are advertised by camera object, not all of them are actually usable. I experienced segfaults on HTC Hero when I tried maximal resolution - data buffer used for passing preview images is mmaped, and this size seems to be limited

like image 122
Konstantin Pribluda Avatar answered Nov 15 '22 14:11

Konstantin Pribluda