Changeset 349
- Timestamp:
- 01/21/07 22:19:45 (2 years ago)
- Files:
-
- trunk/hal/virtual-cam/cc3_hal.h (modified) (1 diff)
- trunk/lib/cc3_ilp/cc3_conv.c (modified) (1 diff)
- trunk/lib/cc3_ilp/cc3_conv.h (modified) (1 diff)
- trunk/projects/polly/Makefile (modified) (1 diff)
- trunk/projects/polly/conv.c (deleted)
- trunk/projects/polly/conv.h (deleted)
- trunk/projects/polly/lreg.c (deleted)
- trunk/projects/polly/lreg.h (deleted)
- trunk/projects/polly/main.c (modified) (3 diffs)
- trunk/projects/polly/polly.c (modified) (9 diffs)
- trunk/projects/polly/polly.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/hal/virtual-cam/cc3_hal.h
r302 r349 34 34 #define VIRTUAL_FIFO_SIZE (640*480*3) 35 35 uint8_t virtual_fifo[VIRTUAL_FIFO_SIZE]; 36 int virtual_fifo_index;36 uint32_t virtual_fifo_index; 37 37 38 38 typedef enum { trunk/lib/cc3_ilp/cc3_conv.c
r343 r349 20 20 if( img.width<kernel.size+1 ) return 0; 21 21 22 mat_div=kernel. size*kernel.size;22 mat_div=kernel.divisor; 23 23 for(j=0; j<img.height-kernel.size+1; j++ ) 24 24 for(i=0; i<img.width-kernel.size+1; i++ ) trunk/lib/cc3_ilp/cc3_conv.h
r343 r349 9 9 typedef struct{ 10 10 uint8_t mat[MAX_KERNEL_SIZE][MAX_KERNEL_SIZE]; 11 uint8_t divisor; 11 12 uint32_t size; 12 13 } cc3_kernel_t; 13 14 14 15 15 int c onvolve(cc3_image_t img, cc3_kernel_t kernel);16 int cc3_convolve_img(cc3_image_t img, cc3_kernel_t kernel); 16 17 17 18 #endif trunk/projects/polly/Makefile
r340 r349 3 3 4 4 # C files to compile 5 CSOURCES=main.c polly.c conv.c lreg.c5 CSOURCES=main.c polly.c 6 6 7 7 # header files 8 INCLUDES=polly.h conv.h lreg.h8 INCLUDES=polly.h 9 9 10 10 # header files trunk/projects/polly/main.c
r341 r349 7 7 #include <cc3.h> 8 8 #include <cc3_ilp.h> 9 #include <cc3_math.h> 9 10 #include "polly.h" 10 11 11 #define MMC_DEBUG 12 13 12 //#define MMC_DEBUG 14 13 15 14 … … 17 16 int main (void) 18 17 { 19 uint32_t last_time, val ;18 uint32_t last_time, val,i; 20 19 char c; 21 20 uint8_t *x_axis; 21 polly_config_t p_config; 22 22 23 23 // setup system … … 50 50 // sample wait command in ms 51 51 cc3_wait_ms (1000); 52 x_axis = malloc(cc3_g_current_frame.width); 53 54 p_config.color_thresh=20; 55 p_config.min_blob_size=20; 56 p_config.connectivity=0; 57 p_config.horizontal_edges=0; 58 p_config.vertical_edges=1; 59 p_config.blur=1; 60 p_config.histogram=malloc(cc3_g_current_frame.width); 52 61 53 62 while (1) { 54 polly_config_t p_config; 55 p_config.color_thresh=20; 56 p_config.min_blob_size=20; 57 p_config.connectivity=0; 58 p_config.horizontal_edges=0; 59 p_config.vertical_edges=1; 60 p_config.blur=1; 61 polly(p_config); 63 double distance; 64 cc3_linear_reg_data_t reg_line; 65 66 polly(p_config); // p_config.histogram gets filled with the return data 67 68 for(i=0; i<cc3_g_current_frame.width; i++ ) 69 x_axis[i]=i; 70 71 72 cc3_linear_reg(x_axis, p_config.histogram, cc3_g_current_frame.width,®_line); 73 74 printf( "b=%f\n",reg_line.b ); 75 printf( "m=%f\n",reg_line.m ); 76 printf( "r^2=%f\n",reg_line.r_sqr ); 77 78 distance=reg_line.m*(cc3_g_current_frame.width/2)+reg_line.b; 79 printf( "distance = %f\n",distance ); 80 81 // convert_histogram_to_ppm (&polly_img, config.histogram); 62 82 63 83 } trunk/projects/polly/polly.c
r343 r349 7 7 #include <cc3.h> 8 8 #include <cc3_ilp.h> 9 #include <cc3_conv.h> 9 10 #include "polly.h" 10 #include "conv.h"11 #include "lreg.h"12 11 13 12 #define MMC_DEBUG 14 13 14 ccr_config_t g_cc_conf; 15 15 16 16 // Constants for connected component blob reduce … … 30 30 uint32_t last_time, val,i; 31 31 char c; 32 filter_t blur;32 cc3_kernel_t blur; 33 33 cc3_pixel_t p; 34 34 cc3_image_t polly_img; 35 35 cc3_image_t img; 36 uint8_t *range; 37 uint8_t *x_axis; 36 38 37 cc3_pixel_t mid_pix; 39 38 cc3_pixel_t right_pix; 40 39 cc3_pixel_t down_pix; 41 reg_data_t reg_line;40 42 41 43 42 // limit the recursive depth … … 74 73 return 0; 75 74 76 range = malloc(polly_img.width); 77 if(range==NULL) 75 if(config.histogram==NULL) 78 76 return 0; 79 77 … … 108 106 blur.mat[1][0]=1; blur.mat[1][1]=1; blur.mat[1][2]=1; 109 107 blur.mat[2][0]=1; blur.mat[2][1]=1; blur.mat[2][2]=1; 110 val=convolve(img,blur); 108 blur.divisor=9; 109 val=cc3_convolve_img(img,blur); 111 110 if(val==0) 112 111 { … … 149 148 matrix_to_pgm (&polly_img); 150 149 #endif 151 generate_polly_histogram (&polly_img, range);150 generate_polly_histogram (&polly_img, config.histogram); 152 151 153 x_axis = malloc(polly_img.width);152 /*x_axis = malloc(polly_img.width); 154 153 for(i=0; i<polly_img.width; i++ ) 155 154 x_axis[i]=i; 156 155 157 156 158 lreg(x_axis, range, polly_img.width,®_line);157 lreg(x_axis, config.histogram, polly_img.width,®_line); 159 158 160 159 printf( "a=%f\n",reg_line.a ); … … 166 165 printf( "distance = %f\n",distance ); 167 166 168 convert_histogram_to_ppm (&polly_img, range);167 convert_histogram_to_ppm (&polly_img, config.histogram); 169 168 170 169 … … 176 175 printf( "H " ); 177 176 for(int i=5; i<polly_img.width; i+=5) 178 printf( "%d ",polly_img.height- range[i] );177 printf( "%d ",polly_img.height-config.histogram[i] ); 179 178 printf( "\r" ); 180 179 */ 181 180 182 181 free (img.pix); // don't forget to free! 183 182 free (polly_img.pix); 184 free (x_axis); 185 free (range); 183 // free (x_axis); 186 184 187 185 } … … 406 404 break; 407 405 } 406 407 // Downsample Histogram 408 // for (x = 0; x < width - 5; x += 5) { 409 // int min; 410 // min = 100; 411 // for (int i = 0; i < 5; i++) { 412 // if (hist[x + i] < min) 413 // min = hist[x + i]; 414 // } 415 // for (int i = 0; i < 5; i++) 416 // hist[x + i] = min; 417 // } 418 419 420 } 408 421 /* 409 // Downsample Histogram410 for (x = 0; x < width - 5; x += 5) {411 int min;412 min = 100;413 for (int i = 0; i < 5; i++) {414 if (hist[x + i] < min)415 min = hist[x + i];416 }417 for (int i = 0; i < 5; i++)418 hist[x + i] = min;419 }420 */421 422 423 424 425 }426 427 422 void convert_histogram_to_ppm (cc3_image_t * img, uint8_t * hist) 428 423 { … … 448 443 } 449 444 } 450 445 */ 451 446 452 447 trunk/projects/polly/polly.h
r333 r349 1 #ifndef _POLLY_H_ 2 #define _POLLY_H_ 3 1 4 // Constants for connected component blob reduce 2 5 #define SELECTED 255 … … 15 18 uint8_t vertical_edges; 16 19 uint8_t blur; 20 uint8_t *histogram; 17 21 } polly_config_t; 18 22 … … 23 27 } ccr_config_t; 24 28 25 ccr_config_t g_cc_conf;26 29 27 30 int polly( polly_config_t config); … … 35 38 36 39 37 40 #endif
