Monday, August 1, 2011

[android-developers] Droid 3 - Stretched camera preview with size of 240x160 with front-facing camera

I use code like shown below to choose one of the supported preview
sizes for displaying the camera preview. What I am seeing on the
Motorola Droid 3 is that if the chosen preview size is 240 x 160 (an
unusual aspect ratio of 1.5), the preview looks stretched. ie. it
looks like the camera is capturing at a lower aspect ratio (something
like 1.3) and then stretching it to become 240 x 160. If any of the
other supported preview sizes (128x96, 160x120, 176x144, 352x288,
320x240, 640x480) are chosen, the preview looks fine. Also, this only
happens with the front-facing camera. The preview with the rear camera
looks fine at 240 x 160.

Is anyone else seeing this? Is this a known issue? I have also asked
the question at
http://www.droidforums.net/forum/droid-development/163543-stretched-camera-preview-size-160x240-front-facing-camera-droid-3-a.html#post1668852

Thanks,
Shri

Camera.Parameters params = camera.getParameters();
params.setPreviewFormat(ImageFormat.NV21);
params.setPreviewFrameRate(15);
List<Camera.Size> supportedSizes = params.getSupportedPreviewSizes();
// Chose one of the supportedSizes
Camera.Size chosenSize = chooseSize(supportedSizes);
params.setPreviewSize(chosenSize.width, chosenSize.height);
camera.setParameters(params);
Camera.Size previewSize = camera.getParameters().getPreviewSize();

// Set the size of the SurfaceView to be proportional to the
// aspect ratio of the preview size.
LinearLayout.LayoutParams layoutParams = new
LinearLayout.LayoutParams(
previewSize.width * 3, previewSize.height * 3);
mySurfaceView.setLayoutParams(layoutParams);

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment