AnsweredAssumed Answered

i.MX6Q USB camera (UVC) MJPEG support on Android6.0

Question asked by Yenyu Chen on Aug 23, 2017
Latest reply on Aug 28, 2017 by Diego Adrian Cuevas

I am trying a 8M USB camera on i.MX6Q platform running Android 6.0, but encounter two questions as following. 

 

1. I observe i.MX6 seems only support YUY2 format, but no MJPEG format supported. How can I try to enable MJPEG format for UVC device?

 

03-22 17:01:47.071 234 234 I FslCameraHAL: static Camera* UvcDevice::newInstance(int32_t, char*, int32_t, int32_t, char*) usb sensor name:uvcvideo,USB 2.0 Camera
03-22 17:01:47.071 234 234 I FslCameraHAL: static Camera* UvcDevice::newInstance(int32_t, char*, int32_t, int32_t, char*) usb sensor:uvcvideo,USB 2.0 Camera use standard UVC device
03-22 17:01:47.071 234 234 I FslCameraHAL: Camera::Camera(int32_t, int32_t, int32_t, char*):0: new camera device
03-22 17:01:47.071 234 234 I FslCameraHAL: camera number is 1
03-22 17:01:47.072 234 234 E cutils-trace: Error opening trace file: Permission denied (13)
03-22 17:01:47.072 234 234 I CameraService: Loaded "Default Camera HAL" camera module
03-22 17:01:47.072 234 234 I FslCameraHAL: int CameraHAL::getCameraInfo(int, camera_info*): camera id 0: info=0xbe8a8678
03-22 17:01:47.072 234 234 E FslCameraHAL: Error: format:MJPG not supported!
03-22 17:01:47.072 234 234 E FslCameraHAL: Error: format:MJPG not supported!

 

2. My USB camera can support below resolution settings:

3264X2448 MJPG 15fps YUY2 2fps
2592X1944 MJPG 15fps YUY2 3fps
2048X1536 MJPG 20fps YUY2 3fps
1600X1200 MJPG 20fps YUY2 10fps
1280X960 MJPG 20fps YUY2 10fps
1024X768 MJPG 30fps YUY2 10fps
800X600 MJPG 30fps YUY2 30fps
640X480 MJPG 30fps YUY2 30fps
But if YUY2 format is used, 3264X2448, 2592X1944 and 2048X1536 resolution will be blocked in i.MX6 libcamera3 HAL.
Because of fps <= 5, after modifying below source code, we can enumerate all resolution settings.
diff --git a/mx6/libcamera3/UvcDevice.cpp b/mx6/libcamera3/UvcDevice.cpp
index 7ee47e2..842dd49 100644
--- a/mx6/libcamera3/UvcDevice.cpp
+++ b/mx6/libcamera3/UvcDevice.cpp
@@ -126,7 +126,7 @@ status_t UvcDevice::initSensorStaticData()
vid_frmval.discrete.denominator,
vid_frmval.discrete.numerator);
if (vid_frmval.discrete.denominator /
- vid_frmval.discrete.numerator >= 5) {
+ vid_frmval.discrete.numerator >= 2) {
mPictureResolutions[pictureCnt++] = vid_frmsize.discrete.width;
mPictureResolutions[pictureCnt++] = vid_frmsize.discrete.height;
}

 

03-22 17:01:47.072 234 234 I FslCameraHAL: enum frame size w:1600, h:1200
03-22 17:01:47.072 234 234 I FslCameraHAL: vid_frmval denominator:10, numeraton:1
03-22 17:01:47.072 234 234 I FslCameraHAL: enum frame size w:3264, h:2448
03-22 17:01:47.072 234 234 I FslCameraHAL: vid_frmval denominator:2, numeraton:1
03-22 17:01:47.072 234 234 I FslCameraHAL: enum frame size w:2592, h:1944
03-22 17:01:47.072 234 234 I FslCameraHAL: vid_frmval denominator:3, numeraton:1
03-22 17:01:47.072 234 234 I FslCameraHAL: enum frame size w:2048, h:1536
03-22 17:01:47.072 234 234 I FslCameraHAL: vid_frmval denominator:3, numeraton:1
03-22 17:01:47.072 234 234 I FslCameraHAL: enum frame size w:1280, h:960
03-22 17:01:47.072 234 234 I FslCameraHAL: vid_frmval denominator:10, numeraton:1
03-22 17:01:47.072 234 234 I FslCameraHAL: enum frame size w:1024, h:768
03-22 17:01:47.072 234 234 I FslCameraHAL: vid_frmval denominator:10, numeraton:1
03-22 17:01:47.072 234 234 I FslCameraHAL: enum frame size w:800, h:600
03-22 17:01:47.072 234 234 I FslCameraHAL: vid_frmval denominator:30, numeraton:1
03-22 17:01:47.072 234 234 I FslCameraHAL: enum frame size w:640, h:480
03-22 17:01:47.072 234 234 I FslCameraHAL: vid_frmval denominator:30, numeraton:1
03-22 17:01:47.073 234 234 I FslCameraHAL: enum frame size w:320, h:240
03-22 17:01:47.073 234 234 I FslCameraHAL: vid_frmval denominator:30, numeraton:1
03-22 17:01:47.073 234 234 I FslCameraHAL: enum frame size w:1600, h:1200
03-22 17:01:47.073 234 234 I FslCameraHAL: vid_frmval denominator:10, numeraton:1
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPictureSizes: 1600 x 1200
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPictureSizes: 3264 x 2448
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPictureSizes: 2592 x 1944
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPictureSizes: 2048 x 1536
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPictureSizes: 1280 x 960
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPictureSizes: 1024 x 768
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPictureSizes: 800 x 600
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPictureSizes: 640 x 480
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPictureSizes: 320 x 240
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPictureSizes: 1600 x 1200
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPreviewSizes: 800 x 600
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPreviewSizes: 640 x 480
03-22 17:01:47.073 234 234 I FslCameraHAL: SupportedPreviewSizes: 320 x 240
03-22 17:01:47.073 234 234 I FslCameraHAL: FrameDuration is 33331760, 30000000000
03-22 17:01:47.073 234 234 I FslCameraHAL: mMaxWidth:3264, mMaxHeight:2448

 

But when I select 3264X2448 resolution to take a picture, the camera will crash as below logs.

If I select 2592X1944 resolution to take a picture then will get a excessive exposure picture.

 

(standard input):01-01 00:05:09.773 218 308 I FslCameraHAL: virtual int32_t UvcDevice::UvcStream::onDeviceStopLocked()
(standard input):01-01 00:05:09.777 218 308 I FslCameraHAL: virtual int32_t DMAStream::freeBuffersLocked()
(standard input):01-01 00:05:09.777 218 308 I FslCameraHAL: freeBufferToIon buffer num:3
(standard input):01-01 00:05:09.778 218 308 I FslCameraHAL: virtual int32_t UvcDevice::UvcStream::onDeviceConfigureLocked()
(standard input):01-01 00:05:09.778 218 308 I FslCameraHAL: virtual int32_t DMAStream::onDeviceConfigureLocked()
(standard input):01-01 00:05:09.778 218 308 I FslCameraHAL: virtual int32_t USPStream::onDeviceConfigureLocked()
(standard input):01-01 00:05:09.778 218 308 I FslCameraHAL: virtual int32_t MMAPStream::onDeviceConfigureLocked()
(standard input):01-01 00:05:09.778 218 308 I FslCameraHAL: Width * Height 3264 x 2448 format YUYV, fps: 15
(standard input):01-01 00:05:09.778 218 308 E FslCameraHAL: width:3264 height:2448 is not supported.
(standard input):01-01 00:05:09.844 218 308 I FslCameraHAL: virtual int32_t DMAStream::allocateBuffersLocked()
(standard input):01-01 00:05:09.844 218 308 I FslCameraHAL: allocateBufferFromIon buffer num:2
(standard input):01-01 00:05:10.069 218 308 I FslCameraHAL: phyalloc ptr:0xa816c000, phy:0x30c00000, ionSize:15982592
(standard input):01-01 00:05:10.196 218 308 I FslCameraHAL: phyalloc ptr:0xa722e000, phy:0x31f00000, ionSize:15982592
(standard input):01-01 00:05:10.196 218 308 I FslCameraHAL: virtual int32_t UvcDevice::UvcStream::onDeviceStartLocked()
(standard input):01-01 00:05:10.196 218 308 I FslCameraHAL: buf[0] length:15980544
(standard input):01-01 00:05:10.196 218 308 I FslCameraHAL: buf[1] length:15980544
(standard input):01-01 00:05:12.673 218 308 E FslCameraHAL: getGpsCoordinates: error reading jpeg Coordinates tag
(standard input):01-01 00:05:12.673 218 308 E FslCameraHAL: getGpsTimeStamp: error reading jpeg TimeStamp tag
(standard input):01-01 00:05:12.673 218 308 E FslCameraHAL: getGpsProcessingMethod: error reading jpeg ProcessingMethod tag
(standard input):01-01 00:05:13.510 1213 1375 E CameraDevice-JV-0: Lost output buffer reported for frame 109
(standard input):01-01 00:05:13.529 1213 1392 W LegacyRequestMapper: mapAeAndFlashMode - Ignore control.aeMode == ON_AUTO_FLASH;camera does not support it
(standard input):01-01 00:05:13.534 218 218 E Camera2Client: startPreviewL: Can't start preview in state STILL_CAPTURE
(standard input):01-01 00:05:13.536 1213 1392 E RequestThread-0: at android.hardware.Camera.startPreview(Native Method)
(standard input):01-01 00:05:13.536 1213 1392 E RequestThread-0: at android.hardware.camera2.legacy.RequestThreadManager.startPreview(RequestThreadManager.java:288)
(standard input):01-01 00:05:13.536 1213 1392 E RequestThread-0: at android.hardware.camera2.legacy.RequestThreadManager.doPreviewCapture(RequestThreadManager.java:330)
(standard input):01-01 00:05:13.536 1213 1392 E RequestThread-0: at android.hardware.camera2.legacy.RequestThreadManager.-wrap3(RequestThreadManager.java)
(standard input):01-01 00:05:13.536 1213 1392 E RequestThread-0: at android.hardware.camera2.legacy.RequestThreadManager$5.handleMessage(RequestThreadManager.java:802)
(standard input):01-01 00:05:13.536 1213 1392 I CameraDeviceState: Legacy camera service transitioning to state ERROR
(standard input):01-01 00:05:13.539 1213 1316 E CAM_FatalErrorHandler: Handling Camera Access Failure:
(standard input):01-01 00:05:13.539 1213 1316 E CAM_FatalErrorHandler: at com.android.camera.FatalErrorHandlerImpl.onGenericCameraAccessFailure(FatalErrorHandlerImpl.java:84)
(standard input):01-01 00:05:13.539 1213 1316 E CAM_FatalErrorHandler: at com.android.camera.one.v2.Camera2OneCameraOpenerImpl$1.onError(Camera2OneCameraOpenerImpl.java:154)
(standard input):01-01 00:05:13.539 1213 1316 E CAM_FatalErrorHandler: at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks$1.run(CameraDeviceImpl.java:1697)
(standard input):01-01 00:05:13.540 1213 1316 E CAM_CameraUtil: Show fatal error dialog
(standard input):01-01 00:05:13.544 218 518 E Camera2Client: startPreviewL: Can't start preview in state STILL_CAPTURE
(standard input):01-01 00:05:13.548 1213 1392 E RequestThread-0: at android.hardware.Camera.startPreview(Native Method)
(standard input):01-01 00:05:13.548 1213 1392 E RequestThread-0: at android.hardware.camera2.legacy.RequestThreadManager.startPreview(RequestThreadManager.java:288)
(standard input):01-01 00:05:13.548 1213 1392 E RequestThread-0: at android.hardware.camera2.legacy.RequestThreadManager.doPreviewCapture(RequestThreadManager.java:330)
(standard input):01-01 00:05:13.548 1213 1392 E RequestThread-0: at android.hardware.camera2.legacy.RequestThreadManager.-wrap3(RequestThreadManager.java)
(standard input):01-01 00:05:13.548 1213 1392 E RequestThread-0: at android.hardware.camera2.legacy.RequestThreadManager$5.handleMessage(RequestThreadManager.java:802)
(standard input):01-01 00:05:15.571 218 308 I FslCameraHAL: insertExifThumbnailImage. ReplaceThumbnail(). ret=1

 

Thank you for any help.

Regards,

Yenyu

Outcomes