Changeset 204
- Timestamp:
- 03/21/06 21:05:40 (3 years ago)
- Files:
-
- trunk/hal/lpc2106-cmucam3/cc3.c (modified) (3 diffs)
- trunk/include/cc3.h (modified) (1 diff)
- trunk/lib/cc3_ilp/cc3_color_track.c (modified) (6 diffs)
- trunk/lib/cc3_ilp/cc3_ilp.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/hal/lpc2106-cmucam3/cc3.c
r202 r204 244 244 245 245 246 uint8_t *cc3_malloc_row (void)246 uint8_t *cc3_malloc_rows (uint32_t rows) 247 247 { 248 248 int channels; … … 254 254 } 255 255 256 return (uint8_t *) malloc (cc3_g_current_frame.width * channels );256 return (uint8_t *) malloc (cc3_g_current_frame.width * channels * rows); 257 257 } 258 258 … … 267 267 * Returns -1 if requesting too many rows 268 268 */ 269 int cc3_pixbuf_read_rows (void * mem, uint32_t rows)269 int cc3_pixbuf_read_rows (void * mem, uint32_t rows) 270 270 { 271 271 trunk/include/cc3.h
r203 r204 96 96 extern cc3_frame_t cc3_g_current_frame; // global that keeps clip, stride 97 97 98 uint8_t *cc3_malloc_row (void);98 uint8_t *cc3_malloc_rows (uint32_t rows); 99 99 100 100 void cc3_pixbuf_load (void); trunk/lib/cc3_ilp/cc3_color_track.c
r202 r204 4 4 #include <stdbool.h> 5 5 #include <stdio.h> 6 #include <stdlib.h> 6 7 7 8 /** … … 20 21 { 21 22 uint16_t y, x; 23 24 uint8_t *row, *pixel; 22 25 23 26 x = pkt->scratch_x; … … 28 31 (pkt->lower_bound.channel[2] > pkt->upper_bound.channel[2])) 29 32 return 0; 33 30 34 pkt->num_pixels = 0; 31 35 pkt->x0 = UINT16_MAX; … … 36 40 pkt->centroid_y = 0; 37 41 38 39 for (y = 0; y < cc3_g_current_frame.height; y++) 42 pixel = row = cc3_malloc_rows(1); 43 44 for (y = 0; y < cc3_g_current_frame.height; y++) { 45 cc3_pixbuf_read_rows(row, 1); 46 40 47 for (x = 0; x < cc3_g_current_frame.width; x++) { 41 48 bool pixel_good = 0; 42 cc3_pixbuf_read (); 49 43 50 if (cc3_g_current_frame.coi == CC3_ALL) { 44 if (cc3_g_current_pixel.channel[0] >= pkt->lower_bound.channel[0] 45 && cc3_g_current_pixel.channel[0] <= pkt->upper_bound.channel[0] 46 && cc3_g_current_pixel.channel[1] >= pkt->lower_bound.channel[1] 47 && cc3_g_current_pixel.channel[1] <= pkt->upper_bound.channel[1] 48 && cc3_g_current_pixel.channel[2] >= pkt->lower_bound.channel[2] 49 && cc3_g_current_pixel.channel[2] <= pkt->upper_bound.channel[2]) 50 pixel_good = 1; 51 if (pixel[0] >= pkt->lower_bound.channel[0] 52 && pixel[0] <= pkt->upper_bound.channel[0] 53 && pixel[1] >= pkt->lower_bound.channel[1] 54 && pixel[1] <= pkt->upper_bound.channel[1] 55 && pixel[2] >= pkt->lower_bound.channel[2] 56 && pixel[2] <= pkt->upper_bound.channel[2]) 57 pixel_good = 1; 58 59 pixel += 3; 51 60 } 52 61 else { 53 if ( cc3_g_current_pixel.channel[cc3_g_current_frame.coi]>=62 if (*pixel >= 54 63 pkt->lower_bound.channel[cc3_g_current_frame.coi] 55 && cc3_g_current_pixel.channel[cc3_g_current_frame.coi] <=64 && pixel [cc3_g_current_frame.coi] <= 56 65 pkt->upper_bound.channel[cc3_g_current_frame.coi]) 57 66 pixel_good = 1; 67 68 pixel++; 58 69 } 59 70 … … 72 83 } 73 84 } 74 85 } 75 86 76 87 if (pkt->num_pixels > 0) { … … 92 103 93 104 } 105 106 free(row); 107 94 108 return 1; 95 109 } trunk/lib/cc3_ilp/cc3_ilp.c
r202 r204 3 3 #include <stdbool.h> 4 4 #include <stdio.h> 5 #include <stdlib.h> 5 6 6 7 void cc3_send_image_direct (void) … … 8 9 uint32_t x, y; 9 10 uint32_t size_x, size_y; 11 uint8_t *row = cc3_malloc_rows(1); 10 12 11 13 cc3_set_led (1); … … 20 22 for (y = 0; y < size_y; y++) { 21 23 putchar (2); 22 for (x = 0; x < size_x; x++) { 23 cc3_pixbuf_read (); 24 putchar (cc3_g_current_pixel.channel[CC3_RED]); 25 putchar (cc3_g_current_pixel.channel[CC3_GREEN]); 26 putchar (cc3_g_current_pixel.channel[CC3_BLUE]); 24 25 cc3_pixbuf_read_rows(row, 1); 26 for (x = 0; x < size_x * 3; x++) { 27 putchar (row[x]); 27 28 } 28 29 } 29 30 putchar (3); 31 32 free(row); 30 33 } 31 34
