Changeset 523
- Timestamp:
- 07/02/07 23:25:00 (1 year ago)
- Files:
-
- trunk/projects/cmucam2/cmucam2.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/projects/cmucam2/cmucam2.c
r504 r523 192 192 static void cmucam2_track_color (cc3_track_pkt_t * t_pkt, 193 193 bool poll_mode, 194 boolline_mode, bool auto_led,194 int8_t line_mode, bool auto_led, 195 195 cmucam2_servo_t * servo_settings, 196 196 bool buf_mode, uint8_t sw_color_space, bool quiet); … … 228 228 uint32_t start_time; 229 229 uint8_t sw_color_space; 230 bool error, poll_mode, line_mode, auto_led, demo_mode, buf_mode; 230 bool error, poll_mode, auto_led, demo_mode, buf_mode; 231 int8_t line_mode; 231 232 cc3_track_pkt_t t_pkt; 232 233 cc3_color_info_pkt_t s_pkt; … … 280 281 auto_led = true; 281 282 poll_mode = false; 282 line_mode = false;283 line_mode = 0; 283 284 buf_mode = false; 284 285 packet_filter_flag = false; … … 614 615 if (arg_list[0] == 0) { 615 616 if (arg_list[1] == 1) 616 line_mode = true; 617 else 618 line_mode = false; 617 line_mode = 1; 618 else if (arg_list[1] == 2) 619 line_mode=2; 620 else 621 line_mode = 0; 619 622 } 620 623 break; … … 1260 1263 void cmucam2_track_color (cc3_track_pkt_t * t_pkt, 1261 1264 bool poll_mode, 1262 boolline_mode, bool auto_led,1265 int8_t line_mode, bool auto_led, 1263 1266 cmucam2_servo_t * servo_settings, bool buf_mode, uint8_t sw_color_space, 1264 1267 bool quiet) … … 1292 1295 lm_width = 0; 1293 1296 lm_height = 0; 1294 if (line_mode ) {1297 if (line_mode==1) { 1295 1298 // FIXME: This doesn't make sense 1296 1299 lm = &t_pkt->binary_scanline; … … 1309 1312 putchar (lm_height); 1310 1313 } 1314 1315 if (line_mode==2) { 1316 // FIXME: This still doesn't make sense 1317 lm = &t_pkt->binary_scanline; 1318 lm_width = img.width / 8; 1319 if (img.width % 8 != 0) 1320 lm_width++; 1321 if (!quiet) 1322 putchar (0xFE); 1323 if (cc3_g_pixbuf_frame.height > 255) 1324 lm_height = 255; 1325 else 1326 lm_height = cc3_g_pixbuf_frame.height; 1327 //if (!quiet) 1328 //putchar (img.width); 1329 if (!quiet) 1330 putchar (lm_height); 1331 } 1332 1333 1311 1334 while (cc3_pixbuf_read_rows (img.pix, 1)) { 1312 1335 if(sw_color_space==HSV_COLOR && img.channels==CC3_CHANNEL_ALL) cc3_rgb2hsv_row(img.pix,img.width); 1313 1336 cc3_track_color_scanline (&img, t_pkt); 1314 if (line_mode) { 1337 1338 if (line_mode==1) { 1315 1339 // keep this check here if you don't want the CMUcam2 GUI to hang after exiting a command in line mode 1316 1340 while (!cc3_uart_has_data (0)) { … … 1331 1355 } 1332 1356 } 1357 1358 1359 if (line_mode==2) { 1360 uint8_t min,max,p_count,conf; 1361 uint32_t mean; 1362 // keep this check here if you don't want the CMUcam2 GUI to hang after exiting a command in line mode 1363 while (!cc3_uart_has_data (0)) { 1364 if (getchar () == '\r') { 1365 free (img.pix); 1366 return; 1367 } 1368 } 1369 mean=0; 1370 min=255; 1371 max=0; 1372 p_count=0; 1373 for (int j = 0; j < img.width; j++) { 1374 uint8_t block, offset; 1375 block = j / 8; 1376 offset = j % 8; 1377 offset = 7 - offset; 1378 if((lm[block] & (1<<offset))!=0) 1379 { 1380 // bit detected 1381 if(j<min) min=j; 1382 if(j>max) max=j; 1383 p_count++; 1384 mean+=j; 1385 } 1386 } 1387 mean=mean/p_count; 1388 conf=((max-min)*100)/p_count; 1389 if (!quiet) 1390 printf( "%c%c%c%c%c",(uint8_t)mean,min,max,p_count,conf); 1391 } 1392 1393 1394 1333 1395 } 1334 1396 // keep this check here if you don't want the CMUcam2 GUI to hang after exiting a command in line mode … … 1340 1402 } 1341 1403 cc3_track_color_scanline_finish (t_pkt); 1342 if (line_mode ) {1404 if (line_mode==1) { 1343 1405 if (!quiet) 1344 1406 putchar (0xAA); … … 1346 1408 putchar (0xAA); 1347 1409 } 1410 1411 if (line_mode==2) { 1412 if (!quiet) 1413 putchar (0xFD); 1414 } 1415 1348 1416 if (auto_led) { 1349 1417 if (t_pkt->int_density > 2)
