OV5640 Camera Preview Stretched in Android 11

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OV5640 Camera Preview Stretched in Android 11

1,101 Views
zb2020
Contributor II

I'm using an OV5640 camera (MIPI-CSI) with an i.MX8MP running Android 11 (android-11.0.0_2.6.0). The camera works fine, except the preview in the camera application is stretched. The pictures captured with the camera have the correct aspect ratio; only the preview is stretched. I'm using a 1280x720 display.

Any ideas what the problem could be? Kernel driver? Libcamera?

0 Kudos
Reply
4 Replies

990 Views
norman89till
Contributor I

The issue is likely an aspect ratio mismatch in the HAL (Hardware Abstraction Layer) or camera_config.xml, where the preview resolution being requested doesn't match the display's 16:9 ratio. Check your Camera HIDL implementation to ensure the StreamConfigurationMap provides a preview size that matches the sensor's output without cropping or stretching.

0 Kudos
Reply

1,062 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

This is a aspect‑ratio mismatch between the preview, I suggest you change the camera parameters in Android camera source code. You can take a look about this in section 8.1 Camera configuration of document "Android User's Guide".

Best regards.

0 Kudos
Reply

609 Views
zb2020
Contributor II

I’ve reviewed the camera settings and everything looks correct. One observation: the camera preview only stretches when the camera orientation differs from the display orientation. If I set the orientation to 0, the preview is fine. However, our design requires the camera to be rotated, so I have it set to 90.
It seems like an issue within the Camera2 app - any ideas on what might be causing this?

0 Kudos
Reply

1,009 Views
zb2020
Contributor II

Which camera parameters should I change? Section 8.1 of the Android User's Guide describes the camera setup, but I'm encountering a preview issue. Captured images have the correct aspect ratio, which suggests the camera settings are accurate. The problem is limited to the camera preview in the application, indicating it may be related to the display size or scaling rather than the camera itself. Do you have any suggestions?

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2305386%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EOV5640%20Camera%20Preview%20Stretched%20in%20Android%2011%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2305386%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI'm%20using%20an%20OV5640%20camera%20(MIPI-CSI)%20with%20an%20i.MX8MP%20running%20Android%2011%20(android-11.0.0_2.6.0).%20The%20camera%20works%20fine%2C%20except%20the%20preview%20in%20the%20camera%20application%20is%20stretched.%20The%20pictures%20captured%20with%20the%20camera%20have%20the%20correct%20aspect%20ratio%3B%20only%20the%20preview%20is%20stretched.%20I'm%20using%20a%201280x720%20display.%3CBR%20%2F%3E%3CBR%20%2F%3EAny%20ideas%20what%20the%20problem%20could%20be%3F%20Kernel%20driver%3F%20Libcamera%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2312267%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20OV5640%20Camera%20Preview%20Stretched%20in%20Android%2011%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2312267%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3EThis%20is%20a%20aspect%E2%80%91ratio%20mismatch%20between%20the%20preview%2C%20I%20suggest%20you%20change%20the%20camera%20parameters%20in%20Android%20camera%20source%20code.%20You%20can%20take%20a%20look%20about%20this%20in%20section%208.1%20Camera%20configuration%20of%20document%20%22Android%20User's%20Guide%22.%3C%2FP%3E%0A%3CP%3EBest%20regards.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2317208%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20OV5640%20Camera%20Preview%20Stretched%20in%20Android%2011%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2317208%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EWhich%20camera%20parameters%20should%20I%20change%3F%20Section%208.1%20of%20the%20Android%20User's%20Guide%20describes%20the%20camera%20setup%2C%20but%20I'm%20encountering%20a%20preview%20issue.%20Captured%20images%20have%20the%20correct%20aspect%20ratio%2C%20which%20suggests%20the%20camera%20settings%20are%20accurate.%20The%20problem%20is%20limited%20to%20the%20camera%20preview%20in%20the%20application%2C%20indicating%20it%20may%20be%20related%20to%20the%20display%20size%20or%20scaling%20rather%20than%20the%20camera%20itself.%20Do%20you%20have%20any%20suggestions%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2317586%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20OV5640%20Camera%20Preview%20Stretched%20in%20Android%2011%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2317586%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThe%20issue%20is%20likely%20an%20aspect%20ratio%20mismatch%20in%20the%20HAL%20(Hardware%20Abstraction%20Layer)%20or%20camera_config.xml%2C%20where%20the%20preview%20resolution%20being%20requested%20doesn't%20match%20the%20display's%2016%3A9%20ratio.%20Check%20your%20Camera%20HIDL%20implementation%20to%20ensure%20the%20StreamConfigurationMap%20provides%20a%20preview%20size%20that%20matches%20the%20sensor's%20output%20without%20cropping%20or%20stretching.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2349408%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20OV5640%20Camera%20Preview%20Stretched%20in%20Android%2011%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2349408%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%E2%80%99ve%20reviewed%20the%20camera%20settings%20and%20everything%20looks%20correct.%20One%20observation%3A%20the%20camera%20preview%20only%20stretches%20when%20the%20camera%20orientation%20differs%20from%20the%20display%20orientation.%20If%20I%20set%20the%20orientation%20to%200%2C%20the%20preview%20is%20fine.%20However%2C%20our%20design%20requires%20the%20camera%20to%20be%20rotated%2C%20so%20I%20have%20it%20set%20to%2090.%3CBR%20%2F%3EIt%20seems%20like%20an%20issue%20within%20the%20Camera2%20app%20-%20any%20ideas%20on%20what%20might%20be%20causing%20this%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E