YCbCr_422_SP Decoding from Camera.onPreviewFrame Callback

All your problems with Audio, Video and Images.

YCbCr_422_SP Decoding from Camera.onPreviewFrame Callback

Postby dmanpearl » Thu Nov 27, 2008 3:01 am

I found PlusMinus' PizzaTimer example very helpful for setting up my Thread and messaging system. I hope this forum will help as thoroughly with my current YUV decoding problem:

I want to display live camera data through a custom filter.

I am trying to decode the byte[] data buffer returned to Android's Camera.PreviewCallback onCameraFrame() callback function. The data is in YCbCr_422_SP format. I have verified that the first (width*height) bytes are simple Y luminance values that can be displayed (via Bitmap and ImageView) to make a viable gray-scale image. The total number of bytes are (width * height * 3 / 2).

The remaining 1/2 image bytes are clearly used to store U, V (Cb, Cr) data. Therefore, there are 1/4 image bytes for each U, V component (i.e. each U, V component is used for 4 pixels of the image). This looks like 411 or 420 data, not 422, but we have bigger fish to fry.

I cannot determine if the U V data is aligned adjacently, in alternating rows, or in squares as described in this Wikipedia graphical description: http://en.wikipedia.org/wiki/Image:Yuv420.svg. Once I finally determine the structure of the U, V data, I have several equations to convert from YUV to RGB and I have tried many ways of combining the UV data with the luminance data of the first 2/3 of the buffer to no avail. So far I can only display mono-chrome.

If you or anyone on this list can decode the Android YCbCr_422_SP data, please post the solution as soon as you can. Your efforts and generosity will be greatly appreciated.

- Thank you, David Manpearl
Last edited by dmanpearl on Thu Dec 04, 2008 5:00 am, edited 1 time in total.
dmanpearl
Freshman
Freshman
 
Posts: 2
Joined: Thu Nov 27, 2008 2:18 am
Location: Venice, CA

Top

Postby Romulus » Thu Dec 04, 2008 4:52 am

The onCameraFrame() is known bug and you can get only the native

YCbCr_4"20" (interleaved)

images.

I worked on it but finally can't find a native way to convert YCbCr_420 into JPEG, so I can't make a video recorder. Unless anyone have an idea for this, we can just sit and wait Google to fix it.
Romulus
Freshman
Freshman
 
Posts: 5
Joined: Thu Dec 04, 2008 4:46 am

Postby dmanpearl » Thu Dec 04, 2008 5:05 am

I have successfully decoded the Camera.onPreviewFrame YUV 420 data (YCbCr_422_SP) on the G1 cameraphone. The solution is posted here:
http://groups.google.com/group/android- ... 3ddc8abf9b
- David Manpearl
dmanpearl
Freshman
Freshman
 
Posts: 2
Joined: Thu Nov 27, 2008 2:18 am
Location: Venice, CA

Postby Romulus » Thu Dec 04, 2008 11:03 am

How about the speed?
I also decoded it, but one frame takes about 400ms for one JPEG file.
Romulus
Freshman
Freshman
 
Posts: 5
Joined: Thu Dec 04, 2008 4:46 am

Sample Code

Postby pure » Mon Dec 08, 2008 3:35 pm

It would be really kind if anyone could post a small code snippet showing a view that
uses the camera preview callback and also converts the byte[] data using the YUV converter method posted above.
pure
Freshman
Freshman
 
Posts: 4
Joined: Sun Dec 07, 2008 4:25 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 15 guests