Changeset 455
- Timestamp:
- 02/18/07 21:52:39 (2 years ago)
- Files:
-
- trunk/hal/lpc2106-cmucam3/cc3.c (modified) (12 diffs)
- trunk/hal/lpc2106-cmucam3/cc3_hal.c (modified) (2 diffs)
- trunk/hal/lpc2106-cmucam3/cc3_hal.h (modified) (2 diffs)
- trunk/hal/virtual-cam/cc3.c (modified) (10 diffs)
- trunk/hal/virtual-cam/cc3_hal.c (modified) (2 diffs)
- trunk/hal/virtual-cam/cc3_hal.h (modified) (1 diff)
- trunk/include/cc3.h (modified) (17 diffs)
- trunk/projects/cmucam2/cmucam2.c (modified) (20 diffs)
- trunk/projects/edge-follow/main.c (modified) (1 diff)
- trunk/projects/edge-follow/polly.c (modified) (1 diff)
- trunk/projects/hello-world/main.c (modified) (2 diffs)
- trunk/projects/polly/main.c (modified) (1 diff)
- trunk/projects/polly/polly.c (modified) (2 diffs)
- trunk/projects/polly/polly_no_cc3.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/hal/lpc2106-cmucam3/cc3.c
r444 r455 1 1 /* 2 * Copyright 2006 Anthony Rowe and Adam Goode2 * Copyright 2006-2007 Anthony Rowe and Adam Goode 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 38 38 39 39 40 static _cc3_camera_state_t _cc3_g_current_camera_state; 41 40 42 static inline void _cc3_seek_left (void); 41 43 static inline void _cc3_seek_top (void); … … 61 63 static void _cc3_update_frame_bounds (cc3_frame_t *); 62 64 63 static void _cc3_pixbuf_resize (void); 65 static bool _cc3_set_register_state (void); 66 64 67 65 68 void cc3_pixbuf_load () … … 71 74 if (!_cc3_g_current_camera_state.power_state) { 72 75 return; 73 }74 75 if (cc3_g_pixbuf_frame.reset_on_next_load) {76 _cc3_pixbuf_resize();77 76 } 78 77 … … 185 184 *(pixel + off2) = _cc3_pixbuf_read_subpixel (); 186 185 } 187 }188 189 void _cc3_pixbuf_resize ()190 {191 cc3_g_pixbuf_frame.raw_width = _cc3_g_current_camera_state.raw_width;192 cc3_g_pixbuf_frame.raw_height = _cc3_g_current_camera_state.raw_height;193 cc3_pixbuf_frame_reset();194 186 } 195 187 … … 409 401 410 402 /** 411 * cc3_pixbuf_ set_roi():403 * cc3_pixbuf_frame_set_roi(): 412 404 * Sets the region of interest in cc3_frame_t for virtual windowing. 413 405 * This function changes the way data is read from the FIFO. 414 406 */ 415 bool cc3_pixbuf_ set_roi (int16_t x0, int16_t y0, int16_t x1, int16_t y1)407 bool cc3_pixbuf_frame_set_roi (int16_t x0, int16_t y0, int16_t x1, int16_t y1) 416 408 { 417 409 int w = cc3_g_pixbuf_frame.raw_width; … … 465 457 466 458 /** 467 * cc3_pixbuf_ set_subsample():459 * cc3_pixbuf_frame_set_subsample(): 468 460 * Sets the subsampling step and mode in cc3_frame_t. 469 461 * This function changes the way data is read from the FIFO. 470 462 */ 471 bool cc3_pixbuf_ set_subsample (cc3_subsample_mode_t mode, uint8_t x_step,463 bool cc3_pixbuf_frame_set_subsample (cc3_subsample_mode_t mode, uint8_t x_step, 472 464 uint8_t y_step) 473 465 { … … 503 495 504 496 /** 505 * cc3_pixbuf_ set_coi():497 * cc3_pixbuf_frame_set_coi(): 506 498 * Sets the channel of interest 1 or all. 507 499 * This function changes the way data is read from the FIFO. 508 500 */ 509 bool cc3_pixbuf_ set_coi (cc3_channel_t chan)501 bool cc3_pixbuf_frame_set_coi (cc3_channel_t chan) 510 502 { 511 503 if (chan > 4) … … 549 541 result = _cc3_set_register_state (); 550 542 551 _cc3_pixbuf_resize();552 553 543 return result; 554 544 } … … 564 554 cc3_g_pixbuf_frame.y_loc = 0; 565 555 cc3_g_pixbuf_frame.subsample_mode = CC3_SUBSAMPLE_NEAREST; 566 cc3_g_pixbuf_frame.reset_on_next_load = false; 567 568 cc3_pixbuf_set_coi(CC3_CHANNEL_ALL); 556 557 cc3_pixbuf_frame_set_coi(CC3_CHANNEL_ALL); 569 558 570 559 _cc3_update_frame_bounds (&cc3_g_pixbuf_frame); … … 699 688 _cc3_g_current_camera_state.resolution = cam_res; 700 689 _cc3_set_register_state (); // XXX Don't reset all of them, this is just quick and dirty... 701 cc3_g_pixbuf_frame.reset_on_next_load = true;702 690 } 703 691 … … 757 745 return result; 758 746 } 747 748 749 /* 750 * This function goes through the register state structures and sets the corresponding camera registers. 751 * It also updates any internal camera structures such as resolution that may change. 752 */ 753 bool _cc3_set_register_state () 754 { 755 bool result = true; 756 757 switch (_cc3_g_current_camera_state.camera_type) { 758 case _CC3_OV6620: 759 // Set the right data bus mode 760 result &= cc3_camera_set_raw_register (0x14, 0x20); 761 762 // set the power state 763 if (_cc3_g_current_camera_state.power_state) { 764 // wake up the camera 765 result &= cc3_camera_set_raw_register (0x3F, 0x02); 766 } else { 767 // sleep the camera 768 result &= cc3_camera_set_raw_register (0x3F, 0x12); 769 } 770 771 // Set the resolution and update the size flags 772 if (_cc3_g_current_camera_state.resolution == CC3_CAMERA_RESOLUTION_LOW) { 773 cc3_g_pixbuf_frame.raw_width = CC3_LO_RES_WIDTH; // 88 * 2; 774 cc3_g_pixbuf_frame.raw_height = CC3_LO_RES_HEIGHT; // 144; 775 result &= cc3_camera_set_raw_register (0x14, 0x20); 776 } 777 else { 778 cc3_g_pixbuf_frame.raw_width = CC3_HI_RES_WIDTH; // 176 * 2; 779 cc3_g_pixbuf_frame.raw_height = CC3_HI_RES_HEIGHT; //288; 780 result &= cc3_camera_set_raw_register (0x14, 0x00); 781 } 782 783 if (_cc3_g_current_camera_state.auto_exposure) { 784 result &= cc3_camera_set_raw_register (0x13, 0x21); 785 } 786 else { 787 // No auto gain, so lets set brightness and contrast if need be 788 result &= cc3_camera_set_raw_register (0x13, 0x20); 789 if (_cc3_g_current_camera_state.brightness != -1) 790 result &= cc3_camera_set_raw_register (0x06, 791 (_cc3_g_current_camera_state. 792 brightness & 0xFF)); 793 794 if (_cc3_g_current_camera_state.contrast != -1) 795 result &= cc3_camera_set_raw_register (0x05, 796 (_cc3_g_current_camera_state. 797 contrast & 0xFF)); 798 } 799 // Set Colorspace and Auto White Balance 800 result &= cc3_camera_set_raw_register (0x12, 801 0x20 | 802 (_cc3_g_current_camera_state. 803 auto_white_balance << 2) 804 | (_cc3_g_current_camera_state. 805 colorspace << 3)); 806 // Set Frame Clock rate divider 807 result &= 808 cc3_camera_set_raw_register (0x11, 809 _cc3_g_current_camera_state.clock_divider); 810 811 break; 812 813 case _CC3_OV7620: 814 // XXX I need code. The CMUcam2 is kind of wrong, so lets fix it... 815 result = false; 816 break; 817 } 818 819 cc3_pixbuf_frame_reset(); 820 return result; 821 } trunk/hal/lpc2106-cmucam3/cc3_hal.c
r444 r455 21 21 #include "serial.h" 22 22 #include <stdio.h> 23 24 25 _cc3_camera_state_t _cc3_g_current_camera_state;26 23 27 24 … … 146 143 147 144 148 /*149 * This function goes through the register state structures and sets the corresponding camera registers.150 * It also updates any internal camera structures such as resolution that may change.151 */152 bool _cc3_set_register_state ()153 {154 bool result = true;155 156 switch (_cc3_g_current_camera_state.camera_type) {157 case _CC3_OV6620:158 // Set the right data bus mode159 result &= cc3_camera_set_raw_register (0x14, 0x20);160 161 // set the power state162 if (_cc3_g_current_camera_state.power_state) {163 // wake up the camera164 result &= cc3_camera_set_raw_register (0x3F, 0x02);165 } else {166 // sleep the camera167 result &= cc3_camera_set_raw_register (0x3F, 0x12);168 }169 170 // Set the resolution and update the size flags171 if (_cc3_g_current_camera_state.resolution == CC3_CAMERA_RESOLUTION_LOW) {172 _cc3_g_current_camera_state.raw_width = CC3_LO_RES_WIDTH; // 88 * 2;173 _cc3_g_current_camera_state.raw_height = CC3_LO_RES_HEIGHT; // 144;174 result &= cc3_camera_set_raw_register (0x14, 0x20);175 }176 else {177 _cc3_g_current_camera_state.raw_width = CC3_HI_RES_WIDTH; // 176 * 2;178 _cc3_g_current_camera_state.raw_height = CC3_HI_RES_HEIGHT; //288;179 result &= cc3_camera_set_raw_register (0x14, 0x00);180 }181 182 if (_cc3_g_current_camera_state.auto_exposure) {183 result &= cc3_camera_set_raw_register (0x13, 0x21);184 }185 else {186 // No auto gain, so lets set brightness and contrast if need be187 result &= cc3_camera_set_raw_register (0x13, 0x20);188 if (_cc3_g_current_camera_state.brightness != -1)189 result &= cc3_camera_set_raw_register (0x06,190 (_cc3_g_current_camera_state.191 brightness & 0xFF));192 193 if (_cc3_g_current_camera_state.contrast != -1)194 result &= cc3_camera_set_raw_register (0x05,195 (_cc3_g_current_camera_state.196 contrast & 0xFF));197 }198 // Set Colorspace and Auto White Balance199 result &= cc3_camera_set_raw_register (0x12,200 0x20 |201 (_cc3_g_current_camera_state.202 auto_white_balance << 2)203 | (_cc3_g_current_camera_state.204 colorspace << 3));205 // Set Frame Clock rate divider206 result &=207 cc3_camera_set_raw_register (0x11,208 _cc3_g_current_camera_state.clock_divider);209 210 break;211 212 case _CC3_OV7620:213 // XXX I need code. The CMUcam2 is kind of wrong, so lets fix it...214 result = false;215 break;216 }217 218 return result;219 }trunk/hal/lpc2106-cmucam3/cc3_hal.h
r444 r455 50 50 typedef struct { 51 51 _cc3_camera_type_t camera_type; 52 uint16_t raw_width;53 uint16_t raw_height;54 52 int16_t brightness; 55 53 int16_t contrast; … … 62 60 } _cc3_camera_state_t; 63 61 64 /**65 * This is the global structure that the different cc3_set_xxxx() functions use in order to maintain consistency66 * if an attribute is changed that shares the same register as others.67 */68 extern _cc3_camera_state_t _cc3_g_current_camera_state;69 70 62 // called only from startup.s 71 63 void _cc3_system_setup (void); 72 64 73 bool _cc3_set_register_state (void);74 65 void _cc3_camera_reset (void); 75 66 void _cc3_fifo_reset (void); trunk/hal/virtual-cam/cc3.c
r446 r455 1 1 /* 2 * Copyright 2006 Anthony Rowe and Adam Goode2 * Copyright 2006-2007 Anthony Rowe and Adam Goode 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 60 60 61 61 static void _cc3_update_frame_bounds (cc3_frame_t *); 62 static void _cc3_resize_pixbuf (void);63 62 64 63 void cc3_pixbuf_load () … … 71 70 static int img_cnt=0; 72 71 73 if (cc3_g_pixbuf_frame.reset_on_next_load) {74 _cc3_resize_pixbuf();75 }76 72 77 73 if( _cc3_virtual_cam_path_prefix==NULL ) … … 306 302 } 307 303 308 void _cc3_resize_pixbuf ()309 {310 cc3_g_pixbuf_frame.raw_width = _cc3_g_current_camera_state.raw_width;311 cc3_g_pixbuf_frame.raw_height = _cc3_g_current_camera_state.raw_height;312 313 }314 315 304 uint8_t *cc3_malloc_rows (uint32_t rows) 316 305 { … … 480 469 481 470 /** 482 * cc3_pixbuf_ set_roi():471 * cc3_pixbuf_frame_set_roi(): 483 472 * Sets the region of interest in cc3_frame_t for virtual windowing. 484 473 * This function changes the way data is read from the FIFO. 485 474 * Returns 1 upon success and 0 on an out of bounds failure. 486 475 */ 487 bool cc3_pixbuf_ set_roi (int16_t x0, int16_t y0, int16_t x1, int16_t y1)476 bool cc3_pixbuf_frame_set_roi (int16_t x0, int16_t y0, int16_t x1, int16_t y1) 488 477 { 489 478 int w = cc3_g_pixbuf_frame.raw_width; … … 537 526 538 527 /** 539 * cc3_pixbuf_ set_subsample():528 * cc3_pixbuf_frame_set_subsample(): 540 529 * Sets the subsampling step and mode in cc3_frame_t. 541 530 * This function changes the way data is read from the FIFO. 542 531 */ 543 bool cc3_pixbuf_ set_subsample (cc3_subsample_mode_t mode, uint8_t x_step,532 bool cc3_pixbuf_frame_set_subsample (cc3_subsample_mode_t mode, uint8_t x_step, 544 533 uint8_t y_step) 545 534 { … … 575 564 576 565 /** 577 * cc3_pixbuf_ set_coi():566 * cc3_pixbuf_frame_set_coi(): 578 567 * Sets the channel of interest 1 or all. 579 568 * This function changes the way data is read from the FIFO. 580 569 * Returns 1 upon success and 0 on failure. 581 570 */ 582 bool cc3_pixbuf_ set_coi (cc3_channel_t chan)571 bool cc3_pixbuf_frame_set_coi (cc3_channel_t chan) 583 572 { 584 573 if (chan > 4) … … 616 605 _cc3_set_register_state (); 617 606 618 _cc3_resize_pixbuf ();619 607 printf( "cc3_camera_init()\n" ); 620 608 _cc3_virtual_cam_path_prefix = getenv("CC3_VCAM_PATH"); … … 638 626 cc3_g_pixbuf_frame.y_loc = 0; 639 627 cc3_g_pixbuf_frame.subsample_mode = CC3_SUBSAMPLE_NEAREST; 640 cc3_g_pixbuf_frame.reset_on_next_load = false; 641 642 cc3_pixbuf_set_coi(CC3_CHANNEL_ALL); 628 629 cc3_pixbuf_frame_set_coi(CC3_CHANNEL_ALL); 643 630 644 631 _cc3_update_frame_bounds (&cc3_g_pixbuf_frame); … … 715 702 _cc3_g_current_camera_state.resolution = cam_res; 716 703 _cc3_set_register_state (); // XXX Don't reset all of them, this is just quick and dirty... 717 cc3_g_pixbuf_frame.reset_on_next_load = true;718 704 } 719 705 trunk/hal/virtual-cam/cc3_hal.c
r420 r455 105 105 // Set the resolution and update the cc3_g_current_frame size flags 106 106 if (_cc3_g_current_camera_state.resolution == CC3_CAMERA_RESOLUTION_LOW) { 107 _cc3_g_current_camera_state.raw_width = CC3_LO_RES_WIDTH;108 _cc3_g_current_camera_state.raw_height = CC3_LO_RES_HEIGHT;107 cc3_g_pixbuf_frame.raw_width = CC3_LO_RES_WIDTH; 108 cc3_g_pixbuf_frame.raw_height = CC3_LO_RES_HEIGHT; 109 109 // cc3_set_raw_register (0x14, 0x20); 110 110 } 111 111 else { 112 _cc3_g_current_camera_state.raw_width = CC3_HI_RES_WIDTH;113 _cc3_g_current_camera_state.raw_height = CC3_HI_RES_HEIGHT;112 cc3_g_pixbuf_frame.raw_width = CC3_HI_RES_WIDTH; 113 cc3_g_pixbuf_frame.raw_height = CC3_HI_RES_HEIGHT; 114 114 // cc3_set_raw_register (0x14, 0x00); 115 115 } … … 149 149 break; 150 150 } 151 152 151 cc3_pixbuf_frame_reset(); 153 152 } trunk/hal/virtual-cam/cc3_hal.h
r387 r455 60 60 bool auto_white_balance; 61 61 uint8_t resolution; 62 uint16_t raw_width;63 uint16_t raw_height;64 62 _cc3_camera_type_t camera_type; 65 63 } _cc3_camera_state_t; trunk/include/cc3.h
r454 r455 160 160 uint16_t height; /**< Height of clipping region */ 161 161 uint8_t channels; /**< Number of channels */ 162 163 bool reset_on_next_load; /**< \a true if the camera parameters have164 changed */165 162 } cc3_frame_t; 166 163 … … 175 172 * Current parameters for the internal pixbuf, should be 176 173 * considered read only. 177 * @sa cc3_pixbuf_frame_reset()178 174 */ 179 175 extern cc3_frame_t cc3_g_pixbuf_frame; 180 176 181 177 /** 182 * Initialize camera hardware. 178 * Initialize camera hardware. This resets all camera and pixbuf parameters. 183 179 * 184 180 * @return \a true if successful. … … 194 190 /** 195 191 * Take a picture with the camera and load it into the internal pixbuf. 196 * If #cc3_g_pixbuf_frame has cc3_frame_t.reset_on_next_load set,197 * then #cc3_g_pixbuf_frame is completely reset with new values.198 192 */ 199 193 void cc3_pixbuf_load (void); … … 204 198 * to deallocate this memory when you are done. 205 199 * 206 * \warning If you have changed resolution using cc3_set_resolution(),207 * but have not yet called cc3_pixbuf_load(), this function will return208 * the amount of memory corresponding to the old row size.209 *210 200 * @sa cc3_pixbuf_read_rows() 211 201 * … … 217 207 /** 218 208 * Do a row-by-row copy from the pixbuf into a block of memory. 219 * This function takes into account all the parameters listed in209 * This function takes into account all of the parameters listed in 220 210 * #cc3_g_pixbuf_frame. 221 211 * … … 242 232 * @return \a true if successful. 243 233 */ 244 bool cc3_pixbuf_set_roi (int16_t x_0, int16_t y_0, int16_t x_1, int16_t y_1); 234 bool cc3_pixbuf_frame_set_roi (int16_t x_0, 235 int16_t y_0, 236 int16_t x_1, 237 int16_t y_1); 245 238 246 239 /** … … 253 246 * applied even if \a false. 254 247 */ 255 bool cc3_pixbuf_ set_subsample (cc3_subsample_mode_t mode,256 uint8_t x_step,257 uint8_t y_step);248 bool cc3_pixbuf_frame_set_subsample (cc3_subsample_mode_t mode, 249 uint8_t x_step, 250 uint8_t y_step); 258 251 259 252 /** … … 264 257 * @return \a true on success. 265 258 */ 266 bool cc3_pixbuf_ set_coi (cc3_channel_t chan);259 bool cc3_pixbuf_frame_set_coi (cc3_channel_t chan); 267 260 268 261 /** … … 290 283 291 284 /** 292 * Set the power state of the camera and (possibly) pixbuf. Used to285 * Set the power state of the camera and reset #cc3_g_pixbuf_frame. Used to 293 286 * conserve power when the camera is not being used. 294 287 * … … 301 294 302 295 /** 303 * Set the resolution of the camera hardware. This does not have any 304 * effect on the pixbuf or #cc3_g_pixbuf_frame until cc3_pixbuf_load() 305 * is called again. 296 * Set the resolution of the camera hardware and reset #cc3_g_pixbuf_frame. 306 297 * 307 298 * @param[in] res Resolution to set. … … 310 301 311 302 /** 312 * Set the colorspace of the camera .303 * Set the colorspace of the camera and reset #cc3_g_pixbuf_frame. 313 304 * 314 305 * @param[in] colorspace The colorspace. … … 317 308 318 309 /** 319 * Set the framerate divider .310 * Set the framerate divider and reset #cc3_g_pixbuf_frame. 320 311 * 321 312 * @param[in] rate_divider Desired framerate divider. … … 324 315 325 316 /** 326 * Set auto exposure .317 * Set auto exposure and reset #cc3_g_pixbuf_frame. 327 318 * 328 319 * @param[in] ae Auto exposure value. … … 331 322 332 323 /** 333 * Set auto white balance .324 * Set auto white balance and reset #cc3_g_pixbuf_frame. 334 325 * 335 326 * @param[in] wb Auto white balance value. … … 338 329 339 330 /** 340 * Set the brightness .331 * Set the brightness and reset #cc3_g_pixbuf_frame. 341 332 * 342 333 * @param[in] level The level. … … 345 336 346 337 /** 347 * Set contrast .338 * Set contrast and reset #cc3_g_pixbuf_frame. 348 339 * 349 340 * @param[in] level The level. … … 357 348 * manipulation of the camera modes. Currently, this will not set the 358 349 * corresponding cc3 internal data structure that keeps record of the camera 359 * mode .350 * mode, nor will it change #cc3_g_pixbuf_frame. 360 351 * \warning Use with CAUTION. 361 352 * trunk/projects/cmucam2/cmucam2.c
r451 r455 36 36 static const int MAX_LINE = 128; 37 37 38 static const char *VERSION_BANNER= "CMUcam2 v1.00 c6";38 static const char VERSION_BANNER[] = "CMUcam2 v1.00 c6"; 39 39 40 40 typedef enum { … … 224 224 servo_settings.y_report=false; 225 225 demo_mode = false; 226 226 227 227 start_time = cc3_timer_get_current_ms (); 228 228 229 229 do { 230 230 if (cc3_button_get_state () == 1) { … … 261 261 t_pkt.lower_bound.channel[2] = 16; 262 262 t_pkt.upper_bound.channel[2] = 240; 263 264 263 264 265 265 servo_settings.x=SERVO_MID; 266 266 servo_settings.y=SERVO_MID; … … 276 276 cc3_camera_set_resolution (CC3_CAMERA_RESOLUTION_LOW); 277 277 278 cc3_pixbuf_load ();279 280 278 printf ("%s\r", VERSION_BANNER); 281 279 … … 284 282 cc3_gpio_set_mode (2, CC3_GPIO_MODE_SERVO); 285 283 cc3_gpio_set_mode (3, CC3_GPIO_MODE_SERVO); 286 284 287 285 cc3_gpio_set_servo_position (0, SERVO_MID); 288 286 cc3_gpio_set_servo_position (1, SERVO_MID); … … 290 288 cc3_gpio_set_servo_position (3, SERVO_MID); 291 289 292 cc3_pixbuf_ set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 1);290 cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 1); 293 291 294 292 if (demo_mode) { … … 414 412 break; 415 413 416 case SERVO_PARAMETERS:414 case SERVO_PARAMETERS: 417 415 if (n != 6) { 418 416 error = true; … … 428 426 servo_settings.tilt_step=arg_list[5]; 429 427 break; 430 431 case SERVO_MASK:428 429 case SERVO_MASK: 432 430 if (n != 1) { 433 431 error = true; … … 442 440 break; 443 441 444 case HI_RES:442 case HI_RES: 445 443 if (n != 1) { 446 444 error = true; … … 454 452 cc3_camera_set_resolution (CC3_CAMERA_RESOLUTION_LOW); 455 453 456 // re-init fifo 457 cc3_pixbuf_load (); 458 cc3_pixbuf_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 1); 454 cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 1); 459 455 break; 460 456 … … 467 463 h_pkt.bins = arg_list[0]; 468 464 print_ACK (); 469 470 break; 471 472 465 466 break; 467 468 473 469 case TRACK_INVERT: 474 470 if (n != 1 || arg_list[0] > 1) { … … 520 516 //init_jpeg(); 521 517 // cc3_set_resolution(CC3_RES_HIGH); 522 //cc3_pixbuf_ set_subsample (CC3_SUBSAMPLE_NEAREST, 1, 1);518 //cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 1, 1); 523 519 524 520 cc3_jpeg_send_simple (); … … 534 530 break; 535 531 } 536 cc3_pixbuf_ set_coi (arg_list[0]);532 cc3_pixbuf_frame_set_coi (arg_list[0]); 537 533 } 538 534 else if (n > 1) { … … 543 539 print_ACK (); 544 540 cmucam2_send_image_direct (auto_led); 545 cc3_pixbuf_ set_coi (old_coi);541 cc3_pixbuf_frame_set_coi (old_coi); 546 542 break; 547 543 … … 565 561 566 562 print_ACK (); 567 cc3_camera_set_power_state(arg_list[0]); 563 { 564 // save 565 uint16_t x_0 = cc3_g_pixbuf_frame.x0; 566 uint16_t y_0 = cc3_g_pixbuf_frame.y0; 567 uint16_t x_1 = cc3_g_pixbuf_frame.x1; 568 uint16_t y_1 = cc3_g_pixbuf_frame.y1; 569 uint8_t x_step = cc3_g_pixbuf_frame.x_step; 570 uint8_t y_step = cc3_g_pixbuf_frame.y_step; 571 cc3_subsample_mode_t ss_mode = cc3_g_pixbuf_frame.subsample_mode; 572 573 cc3_camera_set_power_state(arg_list[0]); 574 575 // restore 576 cc3_pixbuf_frame_set_roi(x_0, y_0, x_1, y_1); 577 cc3_pixbuf_frame_set_subsample (ss_mode, x_step, y_step); 578 } 568 579 break; 569 580 … … 575 586 576 587 print_ACK (); 577 cc3_pixbuf_ set_roi (arg_list[0] * 2,578 arg_list[1], arg_list[2] * 2, arg_list[3]);588 cc3_pixbuf_frame_set_roi (arg_list[0] * 2, 589 arg_list[1], arg_list[2] * 2, arg_list[3]); 579 590 break; 580 591 … … 611 622 612 623 print_ACK (); 613 cc3_pixbuf_ set_subsample (CC3_SUBSAMPLE_NEAREST, arg_list[0] * 2,614 arg_list[1]);624 cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, arg_list[0] * 2, 625 arg_list[1]); 615 626 break; 616 627 … … 666 677 y0 = cc3_g_pixbuf_frame.y0 + cc3_g_pixbuf_frame.width / 4; 667 678 y1 = cc3_g_pixbuf_frame.y1 - cc3_g_pixbuf_frame.width / 4; 668 cc3_pixbuf_ set_roi (x0, y0, x1, y1);679 cc3_pixbuf_frame_set_roi (x0, y0, x1, y1); 669 680 // call get mean 670 681 cmucam2_get_mean (&s_pkt, 1, line_mode,buf_mode, 1); … … 674 685 y0 = 0; 675 686 y1 = cc3_g_pixbuf_frame.raw_height; 676 cc3_pixbuf_ set_roi (x0, y0, x1, y1);687 cc3_pixbuf_frame_set_roi (x0, y0, x1, y1); 677 688 // fill in parameters and call track color 678 689 tmp = s_pkt.mean.channel[0] - threshold; … … 845 856 for (x = 0; x < size_x * num_channels; x++) { 846 857 uint8_t p = row[x]; 858 859 // avoid confusion from FIFO corruptions 860 if (p < 16) { 861 p = 16; 862 } else if (p > 240) { 863 p = 240; 864 } 847 865 putchar (p); 848 866 } trunk/projects/edge-follow/main.c
r449 r455 44 44 cc3_camera_set_auto_white_balance (false); 45 45 cc3_camera_set_auto_exposure (true); 46 cc3_pixbuf_ set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2);47 //cc3_pixbuf_ set_coi (CC3_CHANNEL_GREEN);48 cc3_pixbuf_ set_coi (CC3_CHANNEL_ALL);46 cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2); 47 //cc3_pixbuf_frame_set_coi (CC3_CHANNEL_GREEN); 48 cc3_pixbuf_frame_set_coi (CC3_CHANNEL_ALL); 49 49 50 50 cc3_led_set_off (1); trunk/projects/edge-follow/polly.c
r449 r455 72 72 73 73 #ifdef MMC_DEBUG 74 cc3_pixbuf_ set_coi (CC3_ALL);74 cc3_pixbuf_frame_set_coi (CC3_ALL); 75 75 write_raw_fifo_ppm(); 76 cc3_pixbuf_ set_coi (CC3_GREEN);76 cc3_pixbuf_frame_set_coi (CC3_GREEN); 77 77 cc3_pixbuf_rewind(); 78 78 #endif trunk/projects/hello-world/main.c
r431 r455 113 113 // This tells the camera to grab a new frame into the fifo and reset 114 114 // any internal location information. 115 cc3_pixbuf_ set_coi(CC3_CHANNEL_ALL);115 cc3_pixbuf_frame_set_coi(CC3_CHANNEL_ALL); 116 116 cc3_pixbuf_load (); 117 117 … … 172 172 // *** even faster method for red search 173 173 cc3_pixbuf_rewind(); // use exactly the same pixbuf contents 174 cc3_pixbuf_ set_coi(CC3_CHANNEL_RED);174 cc3_pixbuf_frame_set_coi(CC3_CHANNEL_RED); 175 175 start_time = cc3_timer_get_current_ms(); 176 176 max_red = 0; trunk/projects/polly/main.c
r431 r455 40 40 41 41 42 cc3_pixbuf_ set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2);43 cc3_pixbuf_ set_coi (CC3_CHANNEL_GREEN);42 cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2); 43 cc3_pixbuf_frame_set_coi (CC3_CHANNEL_GREEN); 44 44 45 45 cc3_led_set_off (0); trunk/projects/polly/polly.c
r420 r455 53 53 cc3_pixbuf_load(); 54 54 55 cc3_pixbuf_ set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2);56 cc3_pixbuf_ set_coi (CC3_CHANNEL_GREEN);55 cc3_pixbuf_frame_set_subsample (CC3_SUBSAMPLE_NEAREST, 2, 2); 56 cc3_pixbuf_frame_set_coi (CC3_CHANNEL_GREEN); 57 57 58 58 … … 95 95 96 96 #ifdef MMC_DEBUG 97 cc3_pixbuf_ set_coi (CC3_CHANNEL_ALL);97 cc3_pixbuf_frame_set_coi (CC3_CHANNEL_ALL); 98 98 write_raw_fifo_ppm (); 99 cc3_pixbuf_ set_coi (CC3_CHANNEL_GREEN);99 cc3_pixbuf_frame_set_coi (CC3_CHANNEL_GREEN); 100 100 cc3_pixbuf_rewind (); 101 101 #endif trunk/projects/polly/polly_no_cc3.c
r431 r455 55 55 56 56 57 cc3_pixbuf_ set_subsample( CC3_NEAREST, 2, 2 );58 cc3_pixbuf_ set_coi(CC3_RED);57 cc3_pixbuf_frame_set_subsample( CC3_NEAREST, 2, 2 ); 58 cc3_pixbuf_frame_set_coi(CC3_RED); 59 59 60 60 cc3_led_set_off (0);
