Changeset 437

Show
Ignore:
Timestamp:
02/18/07 18:12:57 (2 years ago)
Author:
anthony_rowe
Message:

histogram bug fix

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/cc3-ilp/cc3_histogram.c

    r418 r437  
    3131if(pkt->hist==NULL ) return 0; 
    3232if(cc3_g_pixbuf_frame.coi!=CC3_CHANNEL_ALL) 
    33         pkt->channel=cc3_g_pixbuf_frame.coi; 
     33        pkt->channel=0; //cc3_g_pixbuf_frame.coi; 
    3434for(i=0; i<pkt->bins; i++ ) 
    3535{ 
     
    5151{ 
    5252        uint8_t i; 
    53         cc3_get_pixel( img, x, 0, &cp );       
     53        cc3_get_pixel( img, x, y-pkt->scratch_y, &cp );        
    5454        i=cp.channel[pkt->channel]/pkt->bin_div; 
    5555        if(i>0) i--; 
    5656        if(i>=pkt->bins) i=pkt->bins-1; 
    57         pkt->hist[i-1]++; 
     57        pkt->hist[i]++; 
    5858} 
    5959pkt->scratch_y=y; 
  • trunk/projects/cmucam2/cmucam2.c

    r436 r437  
    6868  GET_INPUT, 
    6969  SET_TRACK, 
     70  CONF_HISTOGRAM, 
    7071  CMUCAM2_CMD_END               // Must be last entry so array sizes are correct 
    7172} cmucam2_command_t; 
     
    117118  // SP servo parameters 
    118119  cmucam2_cmds[SERVO_PARAMETERS] = "SP"; 
    119   cmucam2_cmds[GET_INPUT] = "GI"; 
    120   cmucam2_cmds[SET_INPUT] = "SI"; 
    121120 
    122121 
     
    132131 
    133132  /* Auxiliary I/O Commands */ 
     133  cmucam2_cmds[GET_INPUT] = "GI"; 
     134  cmucam2_cmds[SET_INPUT] = "SI"; 
    134135  //  GB get button 
    135   //  GI get auxiliary I/O 
    136136  cmucam2_cmds[LED_0] = "L0"; 
    137137  //  L1 LED control 
     
    145145  cmucam2_cmds[GET_TRACK] = "GT"; 
    146146  cmucam2_cmds[SET_TRACK] = "ST"; 
    147   //  ST set tracking parameters 
    148147 
    149148  /* Histogram Commands */ 
    150149  cmucam2_cmds[GET_HISTOGRAM] = "GH"; 
     150  cmucam2_cmds[CONF_HISTOGRAM] = "HC"; 
    151151  //  HC histogram config 
    152152  //  HT histogram track 
     
    406406        break; 
    407407 
     408 
     409      case CONF_HISTOGRAM: 
     410        if (n != 1 || arg_list<1 ) { 
     411          error = true; 
     412          break; 
     413        } 
     414        h_pkt.bins = arg_list[0]; 
     415        print_ACK (); 
     416         
     417        break;   
     418 
     419         
    408420      case TRACK_INVERT: 
    409421        if (n != 1 || arg_list[0] > 1) { 
     
    791803  img.pix = malloc (3 * img.width); 
    792804  h_pkt->hist = malloc (h_pkt->bins * sizeof (uint32_t)); 
     805  if(img.pix==NULL || h_pkt->hist==NULL ) 
     806        { 
     807        printf( "INTERNAL ERROR\r" ); 
     808        return; 
     809        } 
    793810  do { 
    794811    cc3_pixbuf_load (); 
     
    800817      while (!cc3_uart_has_data (0)) { 
    801818        if (fgetc (stdin) == '\r') 
     819        { 
    802820          free (img.pix); 
    803         free (h_pkt->hist); 
    804         return; 
     821          free (h_pkt->hist); 
     822          return; 
     823        } 
    805824      } 
    806825      if (!quiet)