Changeset 363

Show
Ignore:
Timestamp:
01/31/07 17:21:00 (2 years ago)
Author:
anthony_rowe
Message:

blah

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/cc3_ilp/Makefile

    r343 r363  
    22LIBS += jpeg-6b 
    33 
    4 CSOURCES = cc3_ilp.c cc3_color_track.c cc3_color_info.c cc3_jpg.c cc3_math.c cc3_conv.c cc3_connected_component.c 
     4CSOURCES = cc3_ilp.c cc3_color_track.c cc3_color_info.c cc3_jpg.c cc3_math.c cc3_conv.c cc3_connected_component.c cc3_img_writer.c 
    55 
    6 INCLUDES = cc3_ilp.h cc3_color_track.h cc3_color_info.h cc3_jpg.h cc3_math.h cc3_conv.h cc3_connected_component.h 
     6INCLUDES = cc3_ilp.h cc3_color_track.h cc3_color_info.h cc3_jpg.h cc3_math.h cc3_conv.h cc3_connected_component.h cc3_img_writer.h 
    77 
    88 
  • trunk/lib/cc3_ilp/cc3_conv.c

    r349 r363  
    1212  The function returns 1 upon success and 0 on failure. 
    1313 */  
    14 int cc3_convolve_img(cc3_image_t img, cc3_kernel_t kernel) 
     14int cc3_convolve_img(cc3_image_t *img, cc3_kernel_t kernel) 
    1515{ 
    1616uint32_t i,j,k,l,mat_div; 
    1717cc3_pixel_t p; 
    1818if(kernel.size>MAX_KERNEL_SIZE) return 0; 
    19 if( img.height<kernel.size+1 ) return 0; 
    20 if( img.width<kernel.size+1 ) return 0; 
     19if( img->height<kernel.size+1 ) return 0; 
     20if( img->width<kernel.size+1 ) return 0; 
    2121 
    2222mat_div=kernel.divisor; 
    23 for(j=0; j<img.height-kernel.size+1; j++ ) 
    24         for(i=0; i<img.width-kernel.size+1; i++ ) 
     23for(j=0; j<img->height-kernel.size+1; j++ ) 
     24        for(i=0; i<img->width-kernel.size+1; i++ ) 
    2525        { 
    2626        uint32_t tmp; 
     
    2929                for(l=0; l<kernel.size; l++ ) 
    3030                { 
    31                 cc3_get_pixel (&img, i+k, j+l, &p);            
     31                cc3_get_pixel (img, i+k, j+l, &p);             
    3232                tmp+=p.channel[0]*kernel.mat[k][l]; 
    3333                } 
     34 
    3435        p.channel[0]=tmp / mat_div; 
    35         cc3_set_pixel (&img, i, j, &p);                
     36        cc3_set_pixel (img, i, j, &p);                 
    3637        } 
    3738return 1; 
  • trunk/lib/cc3_ilp/cc3_conv.h

    r349 r363  
    1414 
    1515 
    16 int cc3_convolve_img(cc3_image_t img, cc3_kernel_t kernel); 
     16int cc3_convolve_img(cc3_image_t *img, cc3_kernel_t kernel); 
    1717 
    1818#endif 
  • trunk/projects/cmucam2/polly.c

    r352 r363  
    107107        blur.mat[2][0]=1; blur.mat[2][1]=1; blur.mat[2][2]=1; 
    108108        blur.divisor=9; 
    109         val=cc3_convolve_img(img,blur); 
     109        val=cc3_convolve_img(&img,blur); 
    110110        if(val==0) 
    111111                { 
  • trunk/projects/polly/main.c

    r351 r363  
    88#include <cc3_ilp.h> 
    99#include <cc3_math.h> 
     10#include <cc3_img_writer.h> 
    1011#include "polly.h" 
    1112 
    1213//#define MMC_DEBUG 
    1314 
     15void draw_line_img(double b,double m,double distance,uint8_t conf); 
    1416 
    1517/* simple hello world, showing features and compiling*/ 
     
    1820  uint32_t last_time, val,i; 
    1921  char c; 
    20   uint8_t *x_axis
     22  uint8_t *x_axis,*h,cnt,conf
    2123  polly_config_t p_config; 
    2224 
     
    5153  cc3_wait_ms (1000); 
    5254  x_axis = malloc(cc3_g_current_frame.width); 
     55  h = malloc(cc3_g_current_frame.width); 
    5356          
    54   p_config.color_thresh=20; 
    55   p_config.min_blob_size=20; 
     57  p_config.color_thresh=10; 
     58  p_config.min_blob_size=30; 
    5659  p_config.connectivity=0; 
    5760  p_config.horizontal_edges=0; 
     
    6770        // p_config.histogram gets filled with the return data 
    6871 
     72        // Prune away points on the histogram that are outliers so they don't 
     73        // get added into the regression line. 
     74        cnt=0; 
    6975        for(i=0; i<cc3_g_current_frame.width; i++ ) 
    70                 x_axis[i]=i; 
    71      
     76        { 
     77                if(p_config.histogram[i]>0 && p_config.histogram[i]<71) 
     78                { 
     79                        h[cnt]=p_config.histogram[i]; 
     80                        x_axis[cnt]=i; 
     81                        cnt++; 
     82                } 
     83        } 
    7284 
    73         cc3_linear_reg(x_axis, p_config.histogram, cc3_g_current_frame.width,&reg_line); 
     85        printf( "cnt = %d\n",cnt ); 
     86        cc3_linear_reg(x_axis, h, cnt,&reg_line); 
    7487 
    7588        printf( "b=%f\n",reg_line.b );      
     
    7992        distance=reg_line.m*(cc3_g_current_frame.width/2)+reg_line.b; 
    8093        printf( "distance = %f\n",distance );  
    81      
     94   
     95        conf=255;        
     96        if(cnt<20) conf=100; 
     97        if(reg_line.r_sqr<.3) conf=100;  
     98        draw_line_img(reg_line.b,reg_line.m,distance,conf); 
    8299    //  convert_histogram_to_ppm (&polly_img, config.histogram); 
    83100         
     
    87104} 
    88105 
     106void draw_line_img(double b,double m,double distance,uint8_t conf) 
     107{ 
     108cc3_image_t img; 
     109cc3_pixel_t p; 
     110uint32_t x; 
     111int32_t y; 
     112 
     113  img.channels = 1; 
     114  img.width = cc3_g_current_frame.width; 
     115  img.height = cc3_g_current_frame.height;     
     116  img.pix = cc3_malloc_rows (cc3_g_current_frame.height); 
     117  if (img.pix == NULL) { 
     118    printf ("Not enough memory...\n"); 
     119    exit (0); 
     120  } 
     121 
     122  p.channel[0]=0; 
     123  for(y=0; y<img.height; y++) 
     124          for(x=0; x<img.width; x++ ) 
     125                cc3_set_pixel (&img, x, y, &p);  
     126 
     127  p.channel[0]=conf; 
     128          for(x=0; x<img.width; x++ ) 
     129                { 
     130                y=(uint32_t)(m*x+b); 
     131                if(y<0 || y>img.height) y=0; 
     132                y=img.height-y; 
     133                cc3_set_pixel (&img, x, y, &p);  
     134                } 
     135cc3_img_write_file_create(&img); 
     136} 
  • trunk/projects/polly/polly.c

    r349 r363  
    88#include <cc3_ilp.h> 
    99#include <cc3_conv.h> 
     10#include <cc3_img_writer.h> 
    1011#include "polly.h" 
    1112 
    1213#define MMC_DEBUG 
     14 
    1315 
    1416ccr_config_t g_cc_conf; 
     
    107109        blur.mat[2][0]=1; blur.mat[2][1]=1; blur.mat[2][2]=1; 
    108110        blur.divisor=9; 
    109         val=cc3_convolve_img(img,blur); 
     111        //val=cc3_img_write_file_create(&img); 
     112        val=cc3_convolve_img(&img,blur); 
     113        //val=cc3_img_write_file_create(&img); 
    110114        if(val==0) 
    111115                { 
    112116                printf( "convolve failed\n" ); 
     117                exit(0); 
    113118                } 
    114119        }  
     
    368373 
    369374 
    370 void generate_polly_histogram (cc3_image_t * img, uint8_t * hist) 
     375void generate_polly_histogram (cc3_image_t * img, int8_t * hist) 
    371376{ 
    372377  int x, y; 
     
    457462  do {  
    458463#ifdef VIRTUAL_CAM 
    459           sprintf(filename, "img%.5d.pgm", pgm_cnt); 
     464          sprintf(filename, "img%.5da.pgm", pgm_cnt); 
    460465#else 
    461466          sprintf(filename, "c:/img%.5d.pgm", pgm_cnt); 
  • trunk/projects/polly/polly.h

    r349 r363  
    1818        uint8_t vertical_edges; 
    1919        uint8_t blur; 
    20         uint8_t *histogram; 
     20        int8_t *histogram; 
    2121} polly_config_t; 
    2222 
     
    3030int polly( polly_config_t config); 
    3131void connected_component_reduce (cc3_image_t * img, ccr_config_t config); 
    32 void generate_polly_histogram (cc3_image_t * img, uint8_t * hist); 
     32void generate_polly_histogram (cc3_image_t * img, int8_t * hist); 
    3333void matrix_to_pgm (cc3_image_t * img); 
    34 void convert_histogram_to_ppm (cc3_image_t * img, uint8_t * hist); 
     34void convert_histogram_to_ppm (cc3_image_t * img, int8_t * hist); 
    3535int count (cc3_image_t * img, int x, int y, int steps); 
    3636int reduce (cc3_image_t * img, int x, int y, int steps, int remove);