Comments on: making YUV conversion a little faster http://www.wordsaretoys.com/2013/10/18/making-yuv-conversion-a-little-faster/ and so on... Fri, 24 Apr 2015 02:43:40 +0000 hourly 1 http://wordpress.org/?v=4.3.1 By: chris http://www.wordsaretoys.com/2013/10/18/making-yuv-conversion-a-little-faster/#comment-73 Sun, 17 Aug 2014 14:25:07 +0000 http://www.wordsaretoys.com/?p=535#comment-73 Hi Eric,

I’m not certain what the code you’ve posted is intended to do. You seem to be building up a table of constants, then there’s this line “for(i=0 ; i>10;” which seems to be cut off…? The code I’ve posted should be resolution independent. Sorry if I’m not getting the point!

Chris

]]>
By: Eric Echeverri http://www.wordsaretoys.com/2013/10/18/making-yuv-conversion-a-little-faster/#comment-72 Sat, 16 Aug 2014 23:50:52 +0000 http://www.wordsaretoys.com/?p=535#comment-72 Hi Chris,

What could be the best way to display a better resolution when the device can output a resolution of 1024*1080. I have the following code that works very well in the android but the resolution is 640 * 480

int width=0;
int height=0;

width = IMG_WIDTH;
height = IMG_HEIGHT;

int frameSize =width*height*2;

int i;

if((!rgb || !ybuf)){
return;
}
int *lrgb = NULL;
int *lybuf = NULL;

lrgb = &rgb[0];
lybuf = &ybuf[0];

if(yuv_tbl_ready==0){
for(i=0 ; i<256 ; i++){
y1192_tbl[i] = 1192*(i-16);
if(y1192_tbl[i]<0){
y1192_tbl[i]=0;
}

v1634_tbl[i] = 1634*(i-128);
v833_tbl[i] = 833*(i-128);
u400_tbl[i] = 400*(i-128);
u2066_tbl[i] = 2066*(i-128);
}
yuv_tbl_ready=1;
}

for(i=0 ; i>10;
int g1 = (y1192_1 – v833_tbl[v] – u400_tbl[u])>>10;
int b1 = (y1192_1 + u2066_tbl[u])>>10;

int y1192_2=y1192_tbl[y2];
int r2 = (y1192_2 + v1634_tbl[v])>>10;
int g2 = (y1192_2 – v833_tbl[v] – u400_tbl[u])>>10;
int b2 = (y1192_2 + u2066_tbl[u])>>10;

r1 = r1>255 ? 255 : r1255 ? 255 : g1255 ? 255 : b1255 ? 255 : r2255 ? 255 : g2255 ? 255 : b2<0 ? 0 : b2;

*lrgb++ = 0xff000000 | b1<<16 | g1<<8 | r1;
*lrgb++ = 0xff000000 | b2<<16 | g2<<8 | r2;

if(lybuf!=NULL){
*lybuf++ = y1;
*lybuf++ = y2;
}
}

]]>
By: chris http://www.wordsaretoys.com/2013/10/18/making-yuv-conversion-a-little-faster/#comment-71 Tue, 04 Mar 2014 12:37:02 +0000 http://www.wordsaretoys.com/?p=535#comment-71 Cool! Glad to see you found a solution.

]]>
By: David Han http://www.wordsaretoys.com/2013/10/18/making-yuv-conversion-a-little-faster/#comment-70 Tue, 04 Mar 2014 07:37:20 +0000 http://www.wordsaretoys.com/?p=535#comment-70 Hi Chris,
Thanks for your reply.
I’ve tried out a solution. In open, the RGB is encoded as BGR, so just change the below line of code,

argb[a++] = 0xff000000 | (b << 16) | (g << 8) | r;

Then

int[] bgrData = new int[previewWidth * previewHeight];
ImageUtils.YUV_NV21_TO_BGR(bgrData, data,
previewWidth, previewHeight);
IplImage bgrImage = IplImage.create(previewWidth, previewHeight,
opencv_core.IPL_DEPTH_8U, 4);
bgrImage.getIntBuffer().put(bgrData);

Maybe this is helpful to others.

Cheers.

]]>
By: chris http://www.wordsaretoys.com/2013/10/18/making-yuv-conversion-a-little-faster/#comment-69 Tue, 04 Mar 2014 05:45:29 +0000 http://www.wordsaretoys.com/?p=535#comment-69 Hi David,

Unfortunately, I’m not familiar with OpenCV, so I can’t give you much help with an IplImage. (I wrote the original code for an Android app.) The RGB format used here is ARGB8888–with 8 bits apiece to store red, green, blue, and alpha channels–but I’m not sure what that translates into for OpenCV. Sorry!

]]>
By: David Han http://www.wordsaretoys.com/2013/10/18/making-yuv-conversion-a-little-faster/#comment-68 Tue, 04 Mar 2014 01:59:54 +0000 http://www.wordsaretoys.com/?p=535#comment-68 Hi Chris,
Search all over the net, finally find the YUV to RGB solution in your article. Thanks.
But after the RGB byte array is generated, how would I use the RGB byte array to generate an IplImage? Could you please give some advice?

Thanks.

]]>
By: roll that camera, zombie: rotation and conversion from YV12 to YUV 420 Planar | words are toys http://www.wordsaretoys.com/2013/10/18/making-yuv-conversion-a-little-faster/#comment-67 Fri, 25 Oct 2013 21:01:27 +0000 http://www.wordsaretoys.com/?p=535#comment-67 […] our last episode, I was converting the NV21 image format from my Android device’s camera into the more […]

]]>