[IGSTK-Users] Conversion YUV2RGB

KubaP kubap27 at interia.eu
Sun Jun 6 08:54:32 EDT 2010


Thank for your reply,

I did it like this:

uyvy2rgb24 (unsigned char * dest, unsigned char * src, int w, int h)
/ / Dest -> new buffer dest
/ / Src -> with frame buffer from device (UYVY)
/ / In -> size of frame in RGB
/ / H -> size of frame in UYVY
(
 unsigned int i;
 dest_offset int = 0;


/ / Iterate UYVY stream in the block of size 4
/ / Because in every block there are two Y-Information (y1, y2) and a Cb (u) and a Cr (v)
  for (i = 0; i <h i + = 4)
  (
unsigned char * r, * b, * g;
unsigned char * y1, * y2, * u * v;

  double fr, fg, fb;
  FY1 double, fy2, fu, fv;

  r = dest + dest_offset;
  g = r + 1;
  b = g + 1;

  u = src + i;
  y1 = u + 1;
  v = y1 + 1;
  y2 = v + 1;

  fu = * u;
  fv = * v;
  FY1 = * y1;
  fy2 = * y2;

  fr = FY1 - 0.0009267 * (fu - 128) + 1.4016868 * (fv - 128);
  fg = FY1 - 0.3436954 * (Fu - 128) - 0.7141690 * (fv - 128);
  FY1 + fb = 1.7721604 * (fu - 128) + 0.0009902 * (fv - 128);

  * R = (unsigned char) (fr> 255? 255: (fr <0? 0: fr));
  * G = (unsigned char) (fg> 255? 255: (fg <0? 0: fg));
  * B = (unsigned char) (fb> 255? 255 (fb <0? 0: fb));


  dest_offset + = 3;

  r = dest + dest_offset;
  g = r + 1;
  b = g + 1;

  fr = fy2 - 0.0009267 * (fu - 128) + 1.4016868 * (fv - 128);
  fg = fy2 - 0.3436954 * (fu - 128) - 0.7141690 * (fv - 128);
  fb = fy2 + 1.7721604 * (fu - 128) + 0.0009902 * (fv - 128);

  * R = (unsigned char) (fr> 255? 255: (fr <0? 0: fr));
  * G = (unsigned char) (fg> 255? 255: (fg <0? 0: fg));
  * B = (unsigned char) (fb> 255? 255 (fb <0? 0: fb));

  dest_offset + = 3;
 )
return h * 1.5;
 )

I have only a slight problem with running it in WebvamWinVideoImager.cxx. Any idea? 



----------------------------------------------------------------------
Markowe buty sportowe w promocyjnych cenach!
Sprawdz: http://linkint.pl/f270d




More information about the IGSTK-Users mailing list