Rose-Hulman Robotics Team

Changeset 518

Show
Ignore:
Timestamp:
06/05/09 13:57:34 (3 years ago)
Author:
spenceal
Message:

removing (by default) debugging messages from vision code

Location:
trunk/software/rb/vision
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/software/rb/vision/_vision.c

    r514 r518  
    3636void free_pixbuf_data(guchar *pixels, gpointer _ipl_image) 
    3737{ 
    38         printf("freeing ipl image data\n"); 
     38        debug("freeing ipl image data\n"); 
    3939        IplImage *ipl_image = _ipl_image; 
    4040        cvReleaseImage(&ipl_image); 
     
    7474        /* Init ccam */ 
    7575        if (!fake_ccam) { 
    76                 printf("Initializing capture\n"); 
     76                debug("Initializing capture\n"); 
    7777                cam = cvCreateCameraCapture(0); 
    7878                if (cam == NULL) 
     
    8181 
    8282        /* Init classifier */ 
    83         printf("Initialzing classifier\n"); 
     83        debug("Initialzing classifier\n"); 
    8484        classifier = classifier_new(classifier_num); 
    8585        classifier_add_data_from_files(classifier, 
     
    104104 
    105105        // TODO: start with a larger list 
    106         printf("generating new pixbuf\n"); 
     106        debug("generating new pixbuf\n"); 
    107107        PyObject *py_points = PyList_New(0); 
    108108 
  • trunk/software/rb/vision/classify.c

    r514 r518  
    1616                        return type; 
    1717        } 
    18         printf("Warning, unknown type: (%f,%f,%f)\n", in[0], in[1], in[2]); 
     18        debug("Warning, unknown type: (%f,%f,%f)\n", in[0], in[1], in[2]); 
    1919        return 0; 
    2020} 
     
    4343        /* Create matrix from image */ 
    4444        int out_rows = size.height * size.width; 
    45         fprintf(stderr, "Creating %dx%d = %d input\n", size.width, size.height, out_rows); 
     45        debug("Creating %dx%d = %d input\n", size.width, size.height, out_rows); 
    4646        CvMat *input = cvCreateMat(out_rows, 3*1, CV_32F); 
    4747        int row, col; 
     
    8585        switch (type) { 
    8686        case RB_DTREE: 
    87                 printf("Using decision tree classifier\n"); 
     87                debug("Using decision tree classifier\n"); 
    8888                classifier->classifier = dtree_create(); 
    8989                break; 
    9090        case RB_HARD: 
    91                 printf("Using hard coded classifier\n"); 
     91                debug("Using hard coded classifier\n"); 
    9292                break; 
    9393        default: 
    94                 fprintf(stderr, "Warning: unknown classifier id %d\n", type); 
     94                debug("Warning: unknown classifier id %d\n", type); 
    9595                break; 
    9696        } 
  • trunk/software/rb/vision/main.c

    r490 r518  
    3030        /* Load image */ 
    3131        if (argc < 2) { 
    32                 printf("usage: %s <image>\n", argv[0]); 
     32                debug("usage: %s <image>\n", argv[0]); 
    3333                return EINVAL; 
    3434        } 
     
    3636        IplImage *input = cvLoadImage(test_file, 1); 
    3737        if (!input) { 
    38                 printf("Could not load image file: %s\n", test_file); 
     38                debug("Could not load image file: %s\n", test_file); 
    3939                return EINVAL; 
    4040        } 
  • trunk/software/rb/vision/vision.c

    r516 r518  
    1818 
    1919#include <stdio.h> 
     20#include <stdarg.h> 
    2021#include <unistd.h> 
    2122#include <errno.h> 
     
    2930#include "classify.h" 
    3031 
     32/* Debugging */ 
     33int debug_level = 0; 
     34void debug(const char *fmt, ...) 
     35{ 
     36        if (debug_level) { 
     37                va_list ap; 
     38                va_start(ap, fmt); 
     39                fprintf(stderr, "DEBUG: "); 
     40                vfprintf(stderr, fmt, ap); 
     41                va_end(ap); 
     42        } 
     43} 
     44 
     45void print_time(const char *label) 
     46{ 
     47        struct timeb tp; 
     48        ftime(&tp); 
     49        debug("%30s  time = %d.%hu\n", label, (int)tp.time, tp.millitm); 
     50} 
    3151 
    3252IplImage *get_image(CvCapture *cam) 
     
    3959                IplImage *image = cvLoadImage(file, 1); 
    4060                if (!image) { 
    41                         printf("Could not load image file: %s\n", file); 
     61                        debug("Could not load image file: %s\n", file); 
    4262                        return NULL; 
    4363                } 
     
    143163                } 
    144164        } 
    145         //printf("found %d/%d white points\n", n, box.width * box.height); 
     165        //debug("found %d/%d white points\n", n, box.width * box.height); 
    146166        if ((double)n / (box.width * box.height) < 0.05) return -1; 
    147167 
     
    191211                        int rval = find_slope_in_box(out, box, &linebox, &yint, &slope); 
    192212                        if (rval == -1) continue; 
    193                         //printf("checking box (%4d,%4d)↔(%4d-%4d): y = %8.3f*x + %8.3f\n", 
     213                        //debug("checking box (%4d,%4d)↔(%4d-%4d): y = %8.3f*x + %8.3f\n", 
    194214                        //       box.x, box.y, box.width, box.height, slope, yint); 
    195215                        if (abs(slope) < 0.5) { 
     
    219239        } 
    220240} 
    221  
    222 void print_time(const char *label) 
    223 { 
    224         struct timeb tp; 
    225         ftime(&tp); 
    226         //fprintf(stderr, "%30s  time = %d.%hu\n", label, (int)tp.time, tp.millitm); 
    227 } 
  • trunk/software/rb/vision/vision.h

    r488 r518  
    104104 
    105105/** 
     106 * Print deubgging message 
     107 */ 
     108void debug(const char *fmt, ...); 
     109 
     110/** 
    106111 * Prints out the given label as well as a timestamps for the current time. 
    107112 * This is used for profiling the software