]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
Comments alignment.
authorPetr Kubiznak <kubizpet@fel.cvut.cz>
Wed, 19 May 2010 18:23:16 +0000 (20:23 +0200)
committerPetr Kubiznak <kubizpet@fel.cvut.cz>
Wed, 19 May 2010 18:23:16 +0000 (20:23 +0200)
src/camera/rozkuk/clr2float.cxx
src/camera/rozkuk/clr2float.h
src/camera/rozkuk/maskgen.cxx
src/camera/rozkuk/masks_globals.h

index e53aa08addcb6f69390b454a8dddc9213284a482..eea1bb83e7f91778ff0080c662e70286d50954ba 100644 (file)
@@ -16,7 +16,7 @@ extern "C" {
 
 /******************************************************************************/
 
-#define TABLE_LEN              256
+#define TABLE_LEN    256
 
 /******************************************************************************/
 
@@ -32,12 +32,12 @@ float currentK = 1.0;
 /******************************************************************************/
 
 /** Initializes the transform table.
- * It can then be used to transform from {0..255} to <-1,1>.
- * @param threshold Value which will transform to zero.
- * @param k Saturation - if k>1.0, differences between positive and negative values grow.
- * @return 0 when table already initialized, 1 if ok */
 * It can then be used to transform from {0..255} to <-1,1>.
 * @param threshold Value which will transform to zero.
 * @param k Saturation - if k>1.0, differences between positive and negative values grow.
 * @return 0 when table already initialized, 1 if ok */
 int initTable(unsigned char threshold, float k) {
-       float divisor;  
+       float divisor;
        if((threshold == currentThr) && (k == currentK)) return 0;
        
        divisor = (float)(threshold > 255-threshold ? threshold : 255-threshold)/k;
@@ -62,7 +62,7 @@ int gray2float(const IplImage *src, CvMat **dest, unsigned char threshold, float
        if(!src) return 0;
        if(initTable(threshold, k) < 0) return 0;
 
-       if(thresholded) cvThreshold(src, thresholded, threshold, 255, CV_THRESH_BINARY);        // threshold (if wanted)
+       if(thresholded) cvThreshold(src, thresholded, threshold, 255, CV_THRESH_BINARY);  // threshold (if wanted)
        
        //if destination matrix is not alloced or of needed properties, create new
        if(!(*dest)) *dest = cvCreateMat(src->height,src->width,CV_32FC1);
@@ -96,7 +96,7 @@ int clr2float(const IplImage *src, CvMat **dest, unsigned char threshold, float
        
        if(src->nChannels > 1) {
                IplImage *gray = cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);  // create new 1-channel 1-byte image
-               cvCvtColor(src, gray, CV_BGR2GRAY);                 // convert to grayscale
+               cvCvtColor(src, gray, CV_BGR2GRAY);             // convert to grayscale
                res = gray2float(gray, dest, threshold, k, thresholded);
                cvReleaseImage(&gray);
        } else res = gray2float(src, dest, threshold, k, thresholded);
index 28aa2c0aaa3c07379be9858b2f20de8cdd88aa02..75383017810668f6bf1006b902a5e83032be325c 100644 (file)
 /******************************************************************************/
 
 /** Transforms a colorful image to its float representation.
- * @param src Image in BGR format.
- * @param dest Pointer to a destination matrix.
- * @param threshold Level of gray which will transform to zero.
- * @param k Saturation - if k>1.0, differences between positive and negative values grow.
- * @param thresholded If not NULL, BW thresholded version of src is stored here.
- * @return Length of the destination data, or 0 if an error occurs. */
 * @param src Image in BGR format.
 * @param dest Pointer to a destination matrix.
 * @param threshold Level of gray which will transform to zero.
 * @param k Saturation - if k>1.0, differences between positive and negative values grow.
 * @param thresholded If not NULL, BW thresholded version of src is stored here.
 * @return Length of the destination data, or 0 if an error occurs. */
 int clr2float(const IplImage *src, CvMat **dest, unsigned char threshold, float k=1.0, IplImage *thresholded=NULL);
 
 /******************************************************************************/
index 7523309c90001b5aaa0241e930a7984572390976..ae0013a20e93de66f05b6f5b3d7703e4b40146ae 100644 (file)
 
 /******************************************************************************/
 
-#define TABLE_LEN              256
+#define TABLE_LEN        256
 
 // color definitions
-#define N                                              CL_NEUTRAL
-#define B                                              0                                       //black
-#define W                                              255                             //white
+#define N                CL_NEUTRAL
+#define B                0                              //black
+#define W                255                            //white
 
 /******************************************************************************/
 
 CvMat *transformTable;
 //table of corns' colors in side masks
 const uchar sideCornColors[SIDEMASKSCNT][CORNSCNT] = {
-  {W,W,B,W,B,N,W,N,N,N},
-  {B,W,W,W,B,N,W,N,N,N},
-  {W,W,W,W,B,N,B,N,N,N},
-  {W,B,W,W,W,N,B,N,N,N},
-  {B,B,W,W,W,N,W,N,N,N},
-  {W,B,B,W,W,N,W,N,N,N},
-  {W,W,B,B,W,N,W,N,N,N},
-  {B,W,W,B,W,N,W,N,N,N},
-  {W,W,W,B,W,N,B,N,N,N}
+       {W,W,B,W,B,N,W,N,N,N},
+       {B,W,W,W,B,N,W,N,N,N},
+       {W,W,W,W,B,N,B,N,N,N},
+       {W,B,W,W,W,N,B,N,N,N},
+       {B,B,W,W,W,N,W,N,N,N},
+       {W,B,B,W,W,N,W,N,N,N},
+       {W,W,B,B,W,N,W,N,N,N},
+       {B,W,W,B,W,N,W,N,N,N},
+       {W,W,W,B,W,N,B,N,N,N}
 };
 //table of corns' colors in central masks
 const uchar centerCornColors[CENTERMASKSCNT][CORNSCNT] = {
-  {N,N,N,N,N,B,N,W,B,W},
-  {N,N,N,N,N,B,N,B,W,W},
-  {N,N,N,N,N,W,N,W,B,B},
-  {N,N,N,N,N,W,N,B,W,B}
+       {N,N,N,N,N,B,N,W,B,W},
+       {N,N,N,N,N,B,N,B,W,W},
+       {N,N,N,N,N,W,N,W,B,B},
+       {N,N,N,N,N,W,N,B,W,B}
 };
 
 /******************************************************************************/
@@ -97,16 +97,16 @@ int generateMasks(const IplImage *src, int blur, char orientation, char teamColo
        
        for(int i=0; i<masksCnt; i++) {
                dest = cvCloneImage(src);
-               replaceTableColors(cornColors, i);                  //adapt look-up table for this mask
+               replaceTableColors(cornColors, i);              //adapt look-up table for this mask
                sprintf(outFilename, "mask%02d%c%c.pnm", i, orientation, teamColor);    //output filename (P=s/c (side/center), C=b/y (blue/yellow))
 
-               cvLUT(src, dest, transformTable);                                                                               //replace colors (apply look-up table)
+               cvLUT(src, dest, transformTable);               //replace colors (apply look-up table)
                if(blur>0) {
-                       if(!(blur%2)) blur++;                                                                                                                   //blur width must be an odd number
-                       cvSmooth(dest, dest, CV_GAUSSIAN, blur);                                        //smooth edges
+                       if(!(blur%2)) blur++;                       //blur width must be an odd number
+                       cvSmooth(dest, dest, CV_GAUSSIAN, blur);    //smooth edges
                }
                
-               if(!cvSaveImage(outFilename,dest))                                                                      //save output image
+               if(!cvSaveImage(outFilename,dest))              //save output image
                        fprintf(stderr, "Could not save: %s\n", outFilename);
                else fprintf(stderr, "File %s saved successfully.\n", outFilename);
                
@@ -119,38 +119,38 @@ int generateMasks(const IplImage *src, int blur, char orientation, char teamColo
 
 int main(int argc, char *argv[]) {
        char opt;
-       int blur=0;                                                             //some default value of blur
+       int blur=0;                                         //some default value of blur
        char color=clBLUE;
        IplImage *mask = NULL;
        
        // scan for program arguments
-  while ((opt = getopt(argc, argv, "yb:")) != -1) {
-    switch (opt) {
-    case 'b':
-      if(optarg) blur = atoi(optarg);                                                                          //threshold
-      break;
-    case 'y':
-      color=clYELLOW;
-      break;
-    }
-  }
-  // there must be exactly one argument (besides optional -b) - mask filename
-  if(argc-optind != 1) {
-       fprintf(stderr, "Invalid program arguments.\n\
-       Call %s mask_filename to generate masks out of masks' mask file.\n\
-       Use optional argument [-b value] to specify the output images blur.\n", argv[0]);
-       return 1;
-  }
+       while ((opt = getopt(argc, argv, "yb:")) != -1) {
+               switch (opt) {
+               case 'b':
+                       if(optarg) blur = atoi(optarg);             //threshold
+                       break;
+               case 'y':
+                       color=clYELLOW;
+                       break;
+               }
+       }
+       // there must be exactly one argument (besides optional -b) - mask filename
+       if(argc-optind != 1) {
+               fprintf(stderr, "Invalid program arguments.\n\
+               Call %s mask_filename to generate masks out of masks' mask file.\n\
+               Use optional argument [-b value] to specify the output images blur.\n", argv[0]);
+               return 1;
+       }
        mask = cvLoadImage(argv[optind], CV_LOAD_IMAGE_GRAYSCALE);  //load mask image (as grayscale)
        if(!mask) {
                fprintf(stderr, "Invalid mask image. File %s cannot be loaded.\n", argv[optind]);
                return 2;
        }
 
-       initTable();                                                                                                                                                                    //fill transformTable with value 128 (gray, i.e. neutral)
+       initTable();                                        //fill transformTable with value 128 (gray, i.e. neutral)
        
        generateMasks(mask, blur, orSIDE, color, sideCornColors, SIDEMASKSCNT);         //generate side masks from the masks' mask
-       generateMasks(mask, blur, orCENTER, color, centerCornColors, CENTERMASKSCNT);           //generate center masks from the masks' mask
+       generateMasks(mask, blur, orCENTER, color, centerCornColors, CENTERMASKSCNT);   //generate center masks from the masks' mask
        
        cvReleaseMat(&transformTable);
        cvReleaseImage(&mask);
index eb3da49239ee2ac51731e7c176da5ae188db1908..b2a5d09be1530b3586e3ab78bec211b1a5986a7b 100644 (file)
 #define CORNSCNT        10    //number of corns in one mask
 #define SIDEMASKSCNT    9     //number of masks for side corns
 #define CENTERMASKSCNT  4     //number of masks for central corns
-#define MASKSCNT                   (SIDEMASKSCNT+CENTERMASKSCNT)                               //number of all masks
+#define MASKSCNT        (SIDEMASKSCNT+CENTERMASKSCNT)   //number of all masks
 
 // color values
-#define CL_NEUTRAL     128                             //neutral color - gray - used also as threshold
+#define CL_NEUTRAL      128   //neutral color - gray - used also as threshold
 
 #endif /* MASKS_GLOBALS */