Convert a RGB565 byte[] to Luminance source

瀏覽次數:307 次
跳到第一則未讀訊息

Umresh

未讀,
2014年9月9日 清晨7:26:072014/9/9
收件者:zx...@googlegroups.com
I have a byte[] of RGB565 and I want to convert it to the YUV byte[]. I tried other methods but i have performance issues(poor performance 4 fps). It'll be faster if I use the incoming RGB byte[].
Guys help me.

Thanks

Lachezar Dobrev

未讀,
2014年9月9日 上午8:20:542014/9/9
收件者:Umresh、zxing
You should "probably" try and use the RGB as luminance source,
rather than converting to YUV and then using that for luminance
source.

com.google.zxing.RGBLuminanceSource
https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/RGBLuminanceSource.java

This implementation is RGB-888, so a RGB-565 might require some
changing in the shift-and-mask operations.
Also this implementation converts the whole frame upfront, which
might not be the best solution, but you can try.

I just realised, that RGB-565 does not fit in a byte. Is it int[],
or is it two bytes per pixel?

Umresh

未讀,
2014年9月9日 上午9:09:302014/9/9
收件者:zx...@googlegroups.com、m.um...@gmail.com

I'm using this vuforia code
if (imageRGB565 != null) {
int imageWidth = imageRGB565.getWidth();
int imageHeight = imageRGB565.getHeight();
int stride = imageRGB565.getStride();
ByteBuffer pixels = imageRGB565.getPixels();
byte[] pixelArray = new byte[pixels.remaining()];
pixels.get(pixelArray, 0, pixelArray.length);

saveCapturedImage(pixelArray, imageWidth, imageHeight);
}
here I get byte[] (pixelArray) and the frame format is set to RGB565. So I converted it to bitmap and used RGBLuminance for bitmap version. I tried pixel version too but it didn't detect but bitmap version detected. The problem is the performance is poor and is there any way to improve it.

Thanks for your help.

Lachezar Dobrev

未讀,
2014年9月10日 凌晨4:35:422014/9/10
收件者:Umresh、zxing
This code seems severely ineffective.
It creates a large byte array, then it seems to perform pre-emptive
conversion of the image.
Are you SURE you need the image? I was left with the impression that
you need to scan the frame for a bar-code. You should try to shorten
the process of bringing the frame into a LuminanceSource instead. A
new implementation of the LuminanceSource should be better.

The code is too short to give any deeper impression.

Umresh

未讀,
2014年9月10日 清晨5:20:482014/9/10
收件者:zx...@googlegroups.com、m.um...@gmail.com
I don't need to save the image but I have to use the data in pixelArray byte[] and its a RGB565. If i convert the byte[] to int[] and use in RGBLuminanceSource I get error.
I convert to int[] saying 3 bytes/pixel and store the values in an int[] then pass to RGBLuminance, it the converts it to byte[]. I get error in
int pixel = pixels[offset + x];
ArrayIndexOutOfBounds
回覆所有人
回覆作者
轉寄
0 則新訊息