|
From: michel X. <mx...@ma...> - 2006-02-25 10:54:42
|
Le Samedi 25 Février 2006 01:37, Luc Saillard a écrit : > On Fri, Feb 24, 2006 at 04:55:18PM -0500, Gabriel A. Devenyi wrote: > > uvccapture is really setup just to create JPEGs by using the MJPEG > > frames. Since its built on the luvcview core, the YUYV capture is present > > in the code, but I've not implemented a method to get it out. I'll dig > > through and see if I can add a YUYV dump, but I'm not even sure of the > > file formatting, so I'll have to do a little research. At the very least > > I'll disallow > > The format is very simple. For each pixel you have two bytes (even: Y and > U) or (odd: U and V). So for an image of 4x4, you have 32 bytes > > 0: YU YV YU YV > 8: YU YV YU YV > 16: YU YV YU YV > 24: YU YV YU YV > > This is very simple but i've not (yet) found a good algorithm when resizing > and converting to other colorspace. You see vertical line. One line will be > blue, the other line will be green. > > Luc > _______________________________________________ > Linux-uvc-devel mailing list > Lin...@li... > http://lists.berlios.de/mailman/listinfo/linux-uvc-devel Luc, Maybe try this one, I have set in luvcview to resize the gui part . In luvcview i only resize the xaxis as y is a constant, this one may resize the two axis. #define ADDRESSE(x,y,w) (((y)*(w))+(x)) typedef struct YU { unsigned char Y0; unsigned char U0; } YU; /* Each pixels in the resulting figure need to be set. For each one take the nearest available in the original surface If the last Chroma component is U take a V else take U by moving the index in the nearest pixel from the left This routine only deal with X axis you need to make the original picture with the good height */ static int resize(unsigned char *INbuff, unsigned char *OUTbuff, int Owidth, int Oheight, int width, int height) { int rx, ry; int xscale,yscale; int x, y; int Cc, lastCc; YU *input = (YU *) INbuff; YU *output = (YU *) OUTbuff; if (!width || !height) return -1; /* at start Cc mean a U component so LastCc should be a V */ lastCc = 1; xscale = (Owidth << 16) / width; yscale =(Oheight << 16) / height; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { rx = x * xscale >> 16; ry = y * yscale >> 16; if (((2 * rx + 1) & 0x03) == 3) Cc = 1; // find V component else Cc = 0; if (lastCc == Cc) { /* no Chroma interleave correct by moving the index */ rx -= 1; Cc = !Cc; } memcpy(output++, &input[ADDRESSE((int) rx, (int) ry, Owidth)], sizeof(YU)); lastCc = Cc; } } return 0; } -- Michel Xhaard http://mxhaard.free.fr |