iMX6 Android camera HAL from freescale does support UVC USB camera, but it just supports few V4L2 formats. We want to use USB camera which supports 720P video stream with MJPEG format. Does anyone patch UvcDevice.cpp to support MJPEG video stream?
The patch is based on kk4.4.2_1.0.0-ga_rc3.
The MJPG feature is mostly realized in UvcMJPGDevice.cpp.
In default, MJPG feature is no enabled.
To use MJPG feature, need
setprop uvc_mjpg 1
ps | grep mediaserver
kill xxx
If you want to make the MJPG feature as default behavior, you can modify come codes.
Currently, support preview, picture, record.Snapshot on recording not supported.
Hi FangHui,
Is there any follow up updates?
I got the same issue as lisztkao, that we both got the error after code patching.
And after changing mPreviewPixelFormat from HAL_PIXEL_FORMAT_YCbCr_422_SP to HAL_PIXEL_FORMAT_YCbCr_420_SP,
I got the preview in Android Camera app but with terrible color.
However, snapshot and recording will generate normal file, unlike preview frame.
Though it's not working on every camera.
MJPEG support is really import in our project, and we are using android 4.2.2 imx6 (sabresd-6dq).
Hope to hear from you with any updates very soon!
Hi, Lin
For MJPG preview, first decode to YUV422, also tell the GPU to proc as YUV422.
If the version you use is jb4.2.2_1.0.0, you can try to update gpu version refer to GPU upgrade to latest p13 for JB4.2.2_1.1.0 release
Hi Fang,
I will try this patch, thanks!.
One more question, since VPU decoder needs 16 pixels align,
when I config the desired resolution to 1920 x 1080 in camera app,
I have to change the number to 1920 x 1088 to avoid ERROR occuring.
Is it still functional if I use 1920x1088? Or I could only use other workable resolutions(like 1280x720)?
Hi Fang,
Yes, I do. But instead I wrote a simple app to access camera through Android Camera API.
Now the camera app can work successfully under several resolutions, such as 640x480, 800x608, 1280x720, and 1600x896(all@30fps).
(Thanks for your tip on preview issue !!)
However, when it comes to 1920x1088@30 fps, the camera will fail.
I kept seeing error message as below:
E/FslCameraHAL( 2291): VPU can't output one frame after feed stream, cap and feed again, capLoop 1
E/FslCameraHAL( 2291): VPU can't output one frame after feed stream, cap and feed again, capLoop 2
......
E/FslCameraHAL( 2291): VPU can't output one frame after feed stream, cap and feed again, capLoop 100
E/FslCameraHAL( 2291): device thread exit with frame = null, 5 buffers still in v4l
E/FslCameraHAL( 2291): handleError handle error:2
E/Camera2 ( 2291): Error condition 2 reported by HAL, arguments 0, 0
Seems it failed to acquire frame at 1920x1088, do you have any thoughts or advise about this issue?
Hi, Lin
Due to uvc driver, cfilledbuffer.length maybe just w*h, not actually the valid mjpg size.
If the resolution is large (such as 1080p), the bit stream may overflow for VPU decoder,
Thus, you can modify codes in UvcMJPGDevice.cpp as below:
JPGLen = cfilledbuffer.length;
to
JPGLen = cfilledbuffer.length/2;
Also, you may modify condes in frameworks/av/services/camera/libcameraservice/api1/client2/Parameters.h
static const unsigned int MAX_PREVIEW_HEIGHT = 1080;
to
static const unsigned int MAX_PREVIEW_HEIGHT = 1088;
I got a strange error after patch the code
[unnamed-3439-0] updateTexImage: clearing GL error: 0x501
Did I lost something?
Thank you
------------------------------------------------------------------------------------
If I change mPreviewPixelFormat from HAL_PIXEL_FORMAT_YCbCr_422_SP to HAL_PIXEL_FORMAT_YCbCr_420_SP,
preview screen will be shown.
However, the color tune is weird.
Hi Fang-san,
Is the following code In UvcMJPGDevice.cpp necessary ?
adjustSensorFormats(sensorFormats, index);
if (mDefaultFormat == 0) {
FLOGE("Error: invalid mDefaultFormat:%d", mDefaultFormat);
return BAD_VALUE;
}
When I disable that code, I can get the MJPEG data with the camera app.
Could you show me the correct code if I'm mistake ?
Best Regards,
Nori
Hi,
It could be possible to add OMX wrapper in Camera HAL and decode MJPEG data and send it to camera app.
@Freescale,
Is this feasible and correct to do decoding of MJPEG data in Camera HAL for USB camera to support higher resolution like 720p and 1080p at 15 or more fps?
This is important feature to have and to use better external camera.
Hi
Is there any update for this issue?
I am also phasing same issue.