Confusion on Yuv Nv21 Conversion to Rgb

Confusion on YUV NV21 conversion to RGB

First of all, I am not super experienced with image encoding (has some limited exposure to this about a year ago). So, take my answer with grain of salt.

However, I believe you are right. I think in their code both
a) V and U are flipped
b) R and B are flipped

I have a feeling that when both of these things are flipped, it will produce the same result as if they arent' flipped. That's the reason why you can find wrong code in many places (originally, somebody got it wrong and after it was copied all over the places, because the resulting code works (however, variables named incorrectly)).

Here is another example of code (which works the same as yours):
http://www.41post.com/3470/programming/android-retrieving-the-camera-preview-as-a-pixel-array

Converting YUV-RGB(Image processing)-YUV during onPreviewFrame in android?

Why not specify that camera preview should provide RGB images?

i.e. Camera.Parameters.setPreviewFormat(ImageFormat.RGB_565);

YUV_NV21_TO_RGB not working?

Your preview size is not 128 by 128 because you fail to set it. You set it on the Camera.Parameters instance but you don't apply it to the camera.

You need to add the following line:

camera.setParameters(param);

And it's probably safe to get the parameters directly from the Camera instance:

preview_format = camera.getPreviewFormat();
Camera.Size sz = camera.getPreviewSize();

Convert YBR_Full image to RGB in java

You need to create Image and set it's value by using your array , then display the image in Jlabel

Like this :

    byte[] imageInByte;////////////this byte array contain your RGB
InputStream in = new ByteArrayInputStream(imageInByte);
BufferedImage bImageFromConvert = ImageIO.read(in);

then You can display bImageFromConvert in JLabel

Like this :

 JLabel jLabel = new JLabel(new ImageIcon(bImageFromConvert ));


Related Topics



Leave a reply



Submit