/home/fwph/code/wurde/rde/utils/WURDECam.cpp

Go to the documentation of this file.
00001 #include <WURDECam.H>
00002 
00003 namespace WURDEVision {
00004         WURDECameraError g_wurdeCamErrno;
00005 
00013         void convert_yuv411_to_yuv24(IplImage *img, unsigned char *src){
00014                 int x,y;
00015                 register unsigned char y0, y1, y2, y3, u, v;
00016                 unsigned char *dest = (unsigned char*) img->imageData;
00017                 
00018                 for (y=img->height; y; y--)
00019                         for (x=img->width >> 2; x; x--) {
00020                                 u  = *(src++);
00021                                 y0 = *(src++);
00022                                 *(dest++) = y0;
00023                                 *(dest++) = u;
00024                                 y1 = *(src++);
00025                                 v  = *(src++);
00026                                 *(dest++) = v;
00027                                 *(dest++) = y1;
00028                                 *(dest++) = u;
00029                                 *(dest++) = v;
00030                                 y2 = *(src++);
00031                                 *(dest++) = y2;
00032                                 *(dest++) = u;
00033                                 *(dest++) = v;
00034                                 y3 = *(src++);
00035                                 *(dest++) = y3;
00036                                 *(dest++) = u;
00037                                 *(dest++) = v;
00038                         }
00039         }
00040 
00041         
00048         void convert_yuv422_to_yuv24(IplImage *img, unsigned char *src){
00049                 // Big note!
00050                 // I'm assuming this is coming in from the camera as yuyv.  It could very well be uyvy.
00051                 // If something is breaking, check this first...
00052                 
00053                 //I think it may actually be uyvy, so we're going to try this. dc1394 provides no guidance...
00054                 
00055                 int x,y;
00056                 register unsigned char y0, y1, u, v;
00057                 unsigned char *dest = (unsigned char*) img->imageData;
00058                 
00059                 for (y=img->height; y; y--){
00060                         for (x=img->width >> 1; x; x--) {
00061                                 /*y0 = *(src++);
00062                                   u = *(src++);
00063                                   y1 = *(src++);
00064                                   v = *(src++);
00065                                 */     
00066                                 u = *(src++);
00067                                 y0 = *(src++);
00068                                 v = *(src++);
00069                                 y1 = *(src++);
00070                                 
00071                         
00072                                 *(dest++) = y0;
00073                                 *(dest++) = u;
00074                                 *(dest++) = v;
00075                                 *(dest++) = y1;
00076                                 *(dest++) = u;
00077                                 *(dest++) = v;
00078                         }
00079                 }
00080                 
00081         }
00082         
00089         void convert_yuv411_to_gray(IplImage *img, unsigned char *src){
00090                 int x,y;
00091                 unsigned char *dest = (unsigned char*) img->imageData;
00092                 
00093                 for (y=img->height; y; y--)
00094                         for (x=img->width >> 2; x; x--) {
00095                                 src++;
00096                                 *(dest++) = *(src++);
00097                                 *(dest++) = *(src++);
00098                                 src++;
00099                                 *(dest++) = *(src++);
00100                                 *(dest++) = *(src++);
00101                         }
00102         }
00103 
00104         void convert_yuv422_to_gray(IplImage *img, unsigned char *src){
00105                 int x,y;
00106                 unsigned char *dest = (unsigned char*) img->imageData;
00107                 
00108                 for (y=img->height; y; y--)
00109                         for (x=img->width >> 1; x; x--) {
00110                                 src++;
00111                                 *(dest++) = *(src++);
00112                                 src++;
00113                                 *(dest++) = *(src++);
00114                         }
00115         }
00116 }

Generated on Thu Feb 1 15:31:54 2007 for WURDE by  doxygen 1.5.1