Changeset 149

Show
Ignore:
Timestamp:
02/26/06 11:30:09 (3 years ago)
Author:
agr
Message:

Color tracking in cvs lib.

Files:

Legend:

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

    r138 r149  
    11LIB = cc3_ilp 
    22 
    3 CSOURCES = cc3_ilp.c 
     3CSOURCES = cc3_ilp.c cc3_color_track.c 
    44 
    5 INCLUDES = cc3_ilp.h 
     5INCLUDES = cc3_ilp.h cc3_color_track.h 
    66 
    77 
  • trunk/lib/cc3_ilp/cc3_ilp.c

    r145 r149  
    6666} 
    6767 
    68 /** 
    69  * cc3_track_color() 
    70  * 
    71  * This function takes parameters set in the  cc3_track_pkt_t structure 
    72  * and fills in the missing parameters with tracked color data. 
    73  * This operates on the image directly from the FIFO. 
    74  * 
    75  * Returns: 0 if the bounds fail, 1 upon sucess 
    76  * 
    77  * Check if num_pixels is greater than 1 to see if an object was detected. 
    78  * 
    79  */ 
    80 uint8_t cc3_track_color(cc3_track_pkt_t *pkt) 
    81 { 
    82 uint32_t mm_x,mm_y; 
    83  int y, x; 
    84  
    85  if( (pkt->lower_bound.channel[0]>pkt->upper_bound.channel[0]) || 
    86      (pkt->lower_bound.channel[1]>pkt->upper_bound.channel[1]) || 
    87      (pkt->lower_bound.channel[2]>pkt->upper_bound.channel[2]) ) return 0; 
    88 pkt->num_pixels=0; 
    89 pkt->x0=UINT16_MAX; 
    90 pkt->y0=UINT16_MAX; 
    91 pkt->x1=0; 
    92 pkt->y1=0; 
    93 mm_x=0; 
    94 mm_y=0; 
    95  
    96 cc3_pixbuf_load(); 
    97 for(y=0; y<cc3_g_current_frame.height; y++ ) 
    98 for(x=0; x<cc3_g_current_frame.width; x++ ) 
    99 { 
    100         bool pixel_good=0; 
    101         cc3_pixbuf_read(); 
    102         if(cc3_g_current_frame.coi==CC3_ALL ) {  
    103                 if(cc3_g_current_pixel.channel[0]>=pkt->lower_bound.channel[0] &&  
    104                 cc3_g_current_pixel.channel[0]<=pkt->upper_bound.channel[0] &&  
    105                 cc3_g_current_pixel.channel[1]>=pkt->lower_bound.channel[1] &&  
    106                 cc3_g_current_pixel.channel[1]<=pkt->upper_bound.channel[1] &&  
    107                 cc3_g_current_pixel.channel[2]>=pkt->lower_bound.channel[2] &&  
    108                 cc3_g_current_pixel.channel[2]<=pkt->upper_bound.channel[2] ) pixel_good=1;  
    109         } else 
    110         { 
    111                 if(cc3_g_current_pixel.channel[cc3_g_current_frame.coi]>=pkt->lower_bound.channel[cc3_g_current_frame.coi] &&  
    112                 cc3_g_current_pixel.channel[cc3_g_current_frame.coi]<=pkt->upper_bound.channel[cc3_g_current_frame.coi] ) pixel_good=1;  
    113         } 
    114  
    115         if(pixel_good) 
    116         { 
    117         pkt->num_pixels++; 
    118         if(pkt->x0 > x ) pkt->x0=x;      
    119         if(pkt->y0 > y ) pkt->y0=y;      
    120         if(pkt->x1 < x ) pkt->x1=x;      
    121         if(pkt->y1 < y ) pkt->y1=y;      
    122         mm_x+=x; 
    123         mm_y+=y; 
    124         } 
    125 } 
    126  
    127  
    128 if(pkt->num_pixels>0 ) 
    129 { 
    130         // FIXME:  Density hack to keep it an integer 
    131         pkt->int_density=(pkt->num_pixels*1000) / ((pkt->x1 - pkt->x0)*(pkt->y1 - pkt->y0)); 
    132         pkt->centroid_x= mm_x / pkt->num_pixels; 
    133         pkt->centroid_y= mm_y / pkt->num_pixels; 
    134  
    135 } 
    136 else  
    137 { 
    138         pkt->int_density=0; 
    139         pkt->x0=0; 
    140         pkt->y0=0; 
    141         pkt->x1=0; 
    142         pkt->y1=0; 
    143         pkt->centroid_x=0; 
    144         pkt->centroid_y=0; 
    145  
    146 } 
    147 return 1; 
    148 } 
    149  
    150 uint8_t cc3_track_color_img(cc3_image_t *img, cc3_track_pkt_t *pkt) 
    151 { 
    15268 
    15369 
    15470 
    15571 
    156 } 
    157  
  • trunk/lib/cc3_ilp/cc3_ilp.h

    r145 r149  
    44#include <stdint.h> 
    55#include "cc3.h" 
     6#include "cc3_color_track.h" 
    67 
    78typedef struct { 
     
    1112} cc3_image_t; 
    1213 
    13 typedef struct { 
    14     uint16_t x0,y0,x1,y1; 
    15     uint16_t centroid_x, centroid_y; 
    16     uint32_t num_pixels; 
    17     uint32_t int_density; 
    18     uint8_t noise_filter; 
    19     cc3_pixel_t upper_bound; 
    20     cc3_pixel_t lower_bound; 
    21 } cc3_track_pkt_t; 
    2214 
    2315void cc3_send_image_direct(void); 
     
    2517void cc3_set_pixel(cc3_image_t *img, uint16_t x, uint16_t y, cc3_pixel_t *in_pix); 
    2618 
    27 uint8_t cc3_track_color(cc3_track_pkt_t *pkt); 
    28 uint8_t cc3_track_color_img(cc3_image_t *img, cc3_track_pkt_t *pkt); 
    2919 
    3020#endif 
  • trunk/projects/cmucam2/main.c

    r146 r149  
    205205while(c!='\r' &&  c!='\n' ) 
    206206{ 
    207 c=getchar(); 
     207c=fgetc(stdin); 
    208208if(length<(MAX_LINE-1))  
    209209        {