MJPEG format in UvcDevice.cpp(i.MX6 Android camera HAL)

cancel
Showing results for 
Search instead for 
Did you mean: 

MJPEG format in UvcDevice.cpp(i.MX6 Android camera HAL)

5,069 Views
stevetsai
Contributor III

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?

   

Labels (2)
17 Replies

478 Views
FangHui
NXP Employee
NXP Employee

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.

478 Views
yilinglin
Contributor II

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!

0 Kudos

478 Views
FangHui
NXP Employee
NXP Employee

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

478 Views
yilinglin
Contributor II

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)?

0 Kudos

478 Views
FangHui
NXP Employee
NXP Employee

Hi, Lin

  To take 1088 picture, seems you should change a little code in native camera apk.

478 Views
yilinglin
Contributor II

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?

0 Kudos

478 Views
FangHui
NXP Employee
NXP Employee

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;

0 Kudos

478 Views
ach_dmatek
Contributor I

I feel no use .

0 Kudos

478 Views
佳杰吴
Contributor I

Hi, i put the uvcMJPG.patch,but it cann't preview ,it shows that IMG_2282.JPG

Platform:

android4.4.2

imx6d

do you have any thoughts or advise about this issue

I

0 Kudos

478 Views
lisztkao
Contributor II

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.

0 Kudos

478 Views
norisugi
Contributor II

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

0 Kudos

478 Views
FangHui
NXP Employee
NXP Employee

Hi, Sugi-san

Seems the usb camera on your side has no format listed in adjustSensorFormats().

Since you just use MJPG format,  so it's ok to disable the codes.

BRs,

Fang Hui

0 Kudos

478 Views
norisugi
Contributor II

Hi Fang-san,

Is it possible to use the pre-installed camera application for capturing the MJPEG data ?

Best Regards,

Nori

0 Kudos

478 Views
mghasan
Contributor I

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.

0 Kudos

478 Views
liyu1
Contributor III

I also have such a demand !!!!!thanks !

0 Kudos

478 Views
QiaopingZhang
Contributor II

me too...

0 Kudos

478 Views
saurabh206
Senior Contributor III

Hi

Is there any update for this issue?

I am also phasing same issue.

0 Kudos