00001
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <stdio.h>
00039 #include <errno.h>
00040 #include <unistd.h>
00041
00042 #include <dc1394/dc1394.h>
00043
00044
00045
00046
00047
00048
00049 #include "pgr_conversions.h"
00050 #include "pgr_stereocam.h"
00051 #include "pgr_registers.h"
00052
00053
00054
00055
00056
00057
00058
00059
00060 #define PFLN {printf("DEBUG PRINT FILE %s LINE %d\n",__FILE__,__LINE__);}
00061
00062
00063 const char* g_szBB3Base = "Bumblebee XB3";
00064 const char* g_szBB2Base = "Bumblebee2";
00065 const char* g_szBBBase = "BumbleBee";
00066
00067
00068 bool
00069 isBumblebeeXB3( dc1394camera_t* camera )
00070 {
00071 if ( !strncmp( camera->model, g_szBB3Base, strlen(g_szBB3Base) ) )
00072 return true;
00073
00074 return false;
00075 }
00076
00077 bool
00078 isBumblebee2( dc1394camera_t* camera )
00079 {
00080 if ( !strncmp( camera->model, g_szBB2Base, strlen(g_szBB2Base) ) )
00081 return true;
00082
00083 return false;
00084 }
00085
00086 bool
00087 isBumblebee( dc1394camera_t* camera )
00088 {
00089 if ( !strncmp( camera->model, g_szBBBase, strlen(g_szBBBase) ) )
00090 return true;
00091
00092 return false;
00093 }
00094
00095 bool isStereoCamera( dc1394camera_t* camera )
00096 {
00097 if ( isBumblebeeXB3( camera ) )
00098 return true;
00099 if ( isBumblebee2( camera ) )
00100 return true;
00101 if ( isBumblebee( camera ) )
00102 return true;
00103
00104 return false;
00105 }
00106
00107
00108 PGRStereoCameraModel_t
00109 getCameraModel( dc1394camera_t* camera )
00110 {
00111 if ( isBumblebeeXB3( camera ) )
00112 return BUMBLEBEEXB3;
00113 else if ( isBumblebee2( camera ) )
00114 return BUMBLEBEE2;
00115 else if ( isBumblebee( camera ) )
00116 return BUMBLEBEE;
00117
00118 return UNKNOWN_CAMERA;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128 dc1394error_t
00129 queryStereoCamera( dc1394camera_t* camera,
00130 PGRStereoCamera_t* stereoCamera )
00131 {
00132
00133
00134 stereoCamera->camera = camera;
00135
00136
00137 stereoCamera->model = getCameraModel( camera );
00138 if ( stereoCamera->model == UNKNOWN_CAMERA )
00139 return DC1394_FAILURE;
00140
00141
00142 dc1394error_t err;
00143
00144 if ( stereoCamera->model != BUMBLEBEE )
00145 {
00146 err = getSensorInfo( camera,
00147 &stereoCamera->bColor,
00148 &stereoCamera->nRows,
00149 &stereoCamera->nCols );
00150 if ( err != DC1394_SUCCESS )
00151 {
00152 fprintf( stderr, "Could not query the Sensor Info Register!\n" );
00153 return err;
00154 }
00155 }
00156 else
00157 {
00158
00159
00160
00161
00162
00163
00164
00165 dc1394video_modes_t video_modes;
00166 err = dc1394_video_get_supported_modes( camera, &video_modes );
00167 if ( err != DC1394_SUCCESS )
00168 {
00169 fprintf( stderr, "Can't get video modes\n" );
00170 return err;
00171 }
00172
00173
00174 printf( "Searching for the highest resolution MONO16 mode available...\n" );
00175 dc1394video_mode_t video_mode;
00176 dc1394color_coding_t coding;
00177 for ( int i = video_modes.num-1; i >= 0; i-- )
00178 {
00179
00180 if ( !dc1394_is_video_mode_scalable( video_modes.modes[i] ) )
00181 {
00182 dc1394_get_color_coding_from_video_mode( camera, video_modes.modes[i], &coding );
00183 if ( coding == DC1394_COLOR_CODING_MONO16 )
00184 {
00185 video_mode = video_modes.modes[i];
00186 break;
00187 }
00188 }
00189 }
00190 if ( video_mode == DC1394_VIDEO_MODE_640x480_MONO16 )
00191 {
00192 stereoCamera->nRows = 480;
00193 stereoCamera->nCols = 640;
00194 }
00195 else if ( video_mode == DC1394_VIDEO_MODE_1024x768_MONO16 )
00196 {
00197 stereoCamera->nRows = 768;
00198 stereoCamera->nCols = 1024;
00199 }
00200 else
00201 {
00202 fprintf( stderr, "Cannot find valid MONO16 video mode!\n" );
00203 return DC1394_FAILURE;
00204 }
00205
00206
00207 dc1394color_filter_t bayerPattern;
00208 err = getBayerTile( stereoCamera->camera, &bayerPattern );
00209 if ( err != DC1394_SUCCESS )
00210 {
00211 fprintf( stderr, "Failed to read the Bayer Tile Pattern register\n" );
00212 return err;
00213 }
00214
00215 if ( bayerPattern == 0 )
00216 stereoCamera->bColor = false;
00217 else
00218 stereoCamera->bColor = true;
00219
00220 }
00221
00222
00223
00224 if ( stereoCamera->nRows == 960 )
00225 {
00226
00227
00228
00229
00230
00231
00232 stereoCamera->nBytesPerPixel = 2;
00233 }
00234 else
00235 {
00236 stereoCamera->nBytesPerPixel = 2;
00237 }
00238
00239 return DC1394_SUCCESS;
00240 }
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 dc1394error_t
00252 setStereoVideoCapture( PGRStereoCamera_t* stereoCamera )
00253 {
00254 dc1394error_t err;
00255 dc1394color_coding_t coding;
00256
00257 switch( stereoCamera->model )
00258 {
00259 case BUMBLEBEE:
00260 dc1394video_mode_t videoMode;
00261 dc1394framerate_t fps;
00262
00263
00264 if ( stereoCamera->nCols == 640 )
00265 {
00266
00267 videoMode = DC1394_VIDEO_MODE_640x480_MONO16;
00268 fps = DC1394_FRAMERATE_30;
00269 }
00270 else
00271 {
00272
00273 videoMode = DC1394_VIDEO_MODE_1024x768_MONO16;
00274 fps = DC1394_FRAMERATE_15;
00275 }
00276
00277
00278 dc1394_video_set_iso_speed( stereoCamera->camera, DC1394_ISO_SPEED_400 );
00279 dc1394_video_set_mode( stereoCamera->camera, videoMode );
00280 dc1394_video_set_framerate( stereoCamera->camera, fps );
00281 err = dc1394_capture_setup( stereoCamera->camera, 1, DC1394_CAPTURE_FLAGS_DEFAULT );
00282 if ( err != DC1394_SUCCESS )
00283 {
00284 fprintf( stderr, "Can't setup Bumblebee capture\n" );
00285 return err;
00286 }
00287 break;
00288
00289 case BUMBLEBEE2:
00290
00291
00292
00293 err = dc1394_memory_load( stereoCamera->camera, 0 );
00294 if ( err != DC1394_SUCCESS )
00295 {
00296 fprintf( stderr, "Can't load default memory channel\n" );
00297 return err;
00298 }
00299
00300
00301 err = setEndian( stereoCamera->camera, false );
00302 if ( err != DC1394_SUCCESS )
00303 {
00304 fprintf( stderr, "Can't set Bumblebee2 into little-endian mode\n" );
00305 return err;
00306 }
00307
00308
00309 coding = DC1394_COLOR_CODING_MONO16;
00310 if ( stereoCamera->bColor )
00311 coding = DC1394_COLOR_CODING_RAW16;
00312
00313 dc1394_video_set_iso_speed( stereoCamera->camera, DC1394_ISO_SPEED_400 );
00314 dc1394_video_set_mode( stereoCamera->camera, DC1394_VIDEO_MODE_FORMAT7_3 );
00315
00316 err = dc1394_format7_set_roi( stereoCamera->camera,
00317 DC1394_VIDEO_MODE_FORMAT7_3,
00318 coding,
00319
00320 DC1394_USE_MAX_AVAIL,
00321 0,
00322 0,
00323 stereoCamera->nCols,
00324 stereoCamera->nRows );
00325 if ( err != DC1394_SUCCESS )
00326 {
00327 fprintf( stderr, "Can't setup Bumblebee2 capture\n" );
00328 return err;
00329 }
00330
00331 err = dc1394_capture_setup( stereoCamera->camera, 1, DC1394_CAPTURE_FLAGS_DEFAULT );
00332 if ( err != DC1394_SUCCESS )
00333 {
00334 fprintf( stderr, "Can't setup Bumblebee capture\n" );
00335 return err;
00336 }
00337 break;
00338
00339 case BUMBLEBEEXB3:
00340
00341
00342
00343 err = dc1394_memory_load( stereoCamera->camera, 0 );
00344 if ( err != DC1394_SUCCESS )
00345 {
00346 fprintf( stderr, "Can't load default memory channel\n" );
00347 return err;
00348 }
00349
00350
00351 if ( stereoCamera->nBytesPerPixel == 2 )
00352 {
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364 err = setEndian( stereoCamera->camera, false );
00365 if ( err != DC1394_SUCCESS )
00366 {
00367 fprintf( stderr, "Can't set Bumblebee2 into little-endian mode\n" );
00368 return err;
00369 }
00370
00371
00372 coding = DC1394_COLOR_CODING_MONO16;
00373 if ( stereoCamera->bColor )
00374 coding = DC1394_COLOR_CODING_RAW16;
00375 }
00376 else
00377 {
00378
00379 coding = DC1394_COLOR_CODING_RGB8;
00380 }
00381
00382
00383
00384
00385 dc1394_video_set_operation_mode( stereoCamera->camera, DC1394_OPERATION_MODE_1394B );
00386 dc1394_video_set_iso_speed( stereoCamera->camera, DC1394_ISO_SPEED_800 );
00387 dc1394_video_set_mode( stereoCamera->camera, DC1394_VIDEO_MODE_FORMAT7_3 );
00388 err = dc1394_format7_set_roi( stereoCamera->camera,
00389 DC1394_VIDEO_MODE_FORMAT7_3,
00390 coding,
00391
00392 DC1394_USE_MAX_AVAIL,
00393 0,
00394 0,
00395 stereoCamera->nCols,
00396 stereoCamera->nRows );
00397 if ( err != DC1394_SUCCESS )
00398 {
00399 fprintf( stderr, "Can't setup Bumblebee XB3 capture\n" );
00400 return err;
00401 }
00402
00403 err = dc1394_capture_setup( stereoCamera->camera, 1, DC1394_CAPTURE_FLAGS_DEFAULT );
00404 if ( err != DC1394_SUCCESS )
00405 {
00406 fprintf( stderr, "Can't setup Bumblebee capture\n" );
00407 return err;
00408 }
00409 break;
00410
00411 default:
00412 fprintf( stderr,
00413 "setStereoVideoCapture() - \n"
00414 "\tThis camera is not a supported stereo camera!\n" );
00415 return DC1394_FAILURE;
00416 }
00417
00418
00419
00420 err = getBayerTile( stereoCamera->camera,
00421 &stereoCamera->bayerTile );
00422 if ( err != DC1394_SUCCESS )
00423 {
00424 fprintf( stderr, "Could not query the Bayer Tile Register!\n" );
00425 return err;
00426 }
00427
00428 return DC1394_SUCCESS;
00429 }
00430
00431
00432
00433
00434
00435
00436
00437
00438 dc1394error_t
00439 startTransmission( PGRStereoCamera_t* stereoCamera )
00440 {
00441 dc1394error_t err;
00442
00443 err = dc1394_video_set_transmission( stereoCamera->camera, DC1394_ON );
00444 if ( err != DC1394_SUCCESS )
00445 {
00446 fprintf( stderr, "Unable to start camera iso transmission\n" );
00447 return err;
00448 }
00449
00450
00451
00452 dc1394switch_t status = DC1394_OFF;
00453
00454 for ( int i = 0; i <= 5; i++ )
00455 {
00456 usleep(50000);
00457
00458
00459 err = dc1394_video_get_transmission( stereoCamera->camera, &status );
00460 if ( err != DC1394_SUCCESS )
00461 {
00462 fprintf( stderr, "Unable to get transmision status\n" );
00463 return err;
00464 }
00465 if ( status != DC1394_OFF )
00466 break;
00467
00468 if( i == 5 )
00469 {
00470 fprintf(stderr,"Camera doesn't seem to want to turn on!\n");
00471 return DC1394_FAILURE;
00472 }
00473 }
00474
00475 return DC1394_SUCCESS;
00476 }
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486 void
00487 extractImagesColor( PGRStereoCamera_t* stereoCamera,
00488 dc1394bayer_method_t bayerMethod,
00489 unsigned char* pucDeInterleaved,
00490 unsigned char* pucRGB,
00491 unsigned char* pucGreen,
00492 unsigned char** ppucRightRGB,
00493 unsigned char** ppucLeftRGB,
00494 unsigned char** ppucCenterRGB,
00495 TriclopsInput* pTriclopsInput )
00496 {
00497
00498 dc1394error_t err;
00499 dc1394video_frame_t* frame;
00500 err = dc1394_capture_dequeue( stereoCamera->camera,
00501 DC1394_CAPTURE_POLICY_WAIT,
00502 &frame );
00503 if ( err != DC1394_SUCCESS )
00504 {
00505 fprintf( stderr, "extractImagesColor - cannot dequeue image!\n" );
00506 return;
00507 }
00508
00509 unsigned char* pucGrabBuffer = frame->image;
00510
00511 if ( stereoCamera->nBytesPerPixel == 2 )
00512 {
00513
00514 dc1394_deinterlace_stereo( pucGrabBuffer,
00515 pucDeInterleaved,
00516 stereoCamera->nCols,
00517 2*stereoCamera->nRows );
00518
00519
00520 dc1394_bayer_decoding_8bit( pucDeInterleaved,
00521 pucRGB,
00522 stereoCamera->nCols,
00523 2*stereoCamera->nRows,
00524 stereoCamera->bayerTile,
00525 bayerMethod );
00526
00527
00528
00529 dc1394_deinterlace_green( pucRGB,
00530 pucGreen,
00531 stereoCamera->nCols,
00532 6*stereoCamera->nRows );
00533 *ppucRightRGB = pucRGB;
00534 *ppucLeftRGB = pucRGB + 3 * stereoCamera->nRows * stereoCamera->nCols;
00535 *ppucCenterRGB = *ppucLeftRGB;
00536 }
00537 else
00538 {
00539 dc1394_deinterlace_rgb( pucGrabBuffer,
00540 pucDeInterleaved,
00541 stereoCamera->nCols,
00542 3*stereoCamera->nRows );
00543
00544
00545 dc1394_bayer_decoding_8bit( pucDeInterleaved,
00546 pucRGB,
00547 stereoCamera->nCols,
00548 3*stereoCamera->nRows,
00549 stereoCamera->bayerTile,
00550 bayerMethod );
00551
00552 dc1394_deinterlace_green( pucRGB,
00553 pucGreen,
00554 stereoCamera->nCols,
00555 9*stereoCamera->nRows );
00556
00557
00558 *ppucRightRGB = pucRGB;
00559 *ppucCenterRGB = pucRGB + 3 * stereoCamera->nRows * stereoCamera->nCols;
00560 *ppucLeftRGB = pucRGB + 6 * stereoCamera->nRows * stereoCamera->nCols;
00561 }
00562
00563 pTriclopsInput->inputType = TriInp_RGB;
00564 pTriclopsInput->nrows = stereoCamera->nRows;
00565 pTriclopsInput->ncols = stereoCamera->nCols;
00566 pTriclopsInput->rowinc = stereoCamera->nCols;
00567 pTriclopsInput->u.rgb.red = pucGreen;
00568 pTriclopsInput->u.rgb.green = pucGreen + stereoCamera->nRows * stereoCamera->nCols;
00569 pTriclopsInput->u.rgb.blue = pTriclopsInput->u.rgb.green;
00570
00571
00572 dc1394_capture_enqueue( stereoCamera->camera, frame );
00573 return;
00574 }
00575
00576
00577
00578
00579
00580
00581
00582 void
00583 extractImagesMono( PGRStereoCamera_t* stereoCamera,
00584 unsigned char* pucDeInterleaved,
00585 unsigned char** ppucRightMono8,
00586 unsigned char** ppucLeftMono8,
00587 unsigned char** ppucCenterMono8,
00588 TriclopsInput* pTriclopsInput )
00589 {
00590
00591 dc1394error_t err;
00592
00593 dc1394video_frame_t* frame;
00594 err = dc1394_capture_dequeue( stereoCamera->camera,
00595 DC1394_CAPTURE_POLICY_WAIT,
00596 &frame );
00597 if ( err != DC1394_SUCCESS )
00598 {
00599 fprintf( stderr, "extractImagesColor - cannot dequeue image!\n" );
00600 return;
00601 }
00602
00603 unsigned char* pucGrabBuffer = frame->image;
00604
00605 unsigned char* right;
00606 unsigned char* left;
00607 unsigned char* center;
00608 if ( stereoCamera->nBytesPerPixel == 2 )
00609 {
00610
00611 dc1394_deinterlace_stereo( pucGrabBuffer,
00612 pucDeInterleaved,
00613 stereoCamera->nCols,
00614 2*stereoCamera->nRows );
00615 right = pucDeInterleaved;
00616 left = pucDeInterleaved + stereoCamera->nRows * stereoCamera->nCols;
00617 center= left;
00618 }
00619 else
00620 {
00621 dc1394_deinterlace_rgb( pucGrabBuffer,
00622 pucDeInterleaved,
00623 stereoCamera->nCols,
00624 3*stereoCamera->nRows );
00625
00626
00627
00628 right = pucDeInterleaved;
00629 center = pucDeInterleaved + stereoCamera->nRows * stereoCamera->nCols;
00630 left = pucDeInterleaved + 2 * stereoCamera->nRows * stereoCamera->nCols;
00631 }
00632
00633 *ppucRightMono8 = right;
00634 *ppucLeftMono8 = left;
00635 *ppucCenterMono8 = center;
00636 pTriclopsInput->inputType = TriInp_RGB;
00637 pTriclopsInput->nrows = stereoCamera->nRows;
00638 pTriclopsInput->ncols = stereoCamera->nCols;
00639 pTriclopsInput->rowinc = stereoCamera->nCols;
00640 pTriclopsInput->u.rgb.red = right;
00641 pTriclopsInput->u.rgb.green = left;
00642 pTriclopsInput->u.rgb.blue = left;
00643
00644
00645 dc1394_capture_enqueue( stereoCamera->camera, frame );
00646
00647 return;
00648 }
00649
00650
00651 #define REG_CONFIG_LENGTH 0x1FFC
00652 #define REG_CONFIG_DATA 0x2000
00653 #define REG_UNIT_DIRECTORY_OFFSET 0x0424
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670 void
00671 extractImagesColorXB3( PGRStereoCamera_t* stereoCamera,
00672 dc1394bayer_method_t bayerMethod,
00673 unsigned char* pucDeInterleaved,
00674 unsigned char* pucRGB,
00675 unsigned char* pucGreen,
00676 unsigned char** ppucRightRGB,
00677 unsigned char** ppucLeftRGB,
00678 unsigned char** ppucCenterRGB,
00679 TriclopsInput* pShortInput,
00680 TriclopsInput* pWideInput )
00681 {
00682
00683 dc1394error_t err;
00684 dc1394video_frame_t* frame;
00685
00686 err = dc1394_capture_dequeue( stereoCamera->camera,
00687 DC1394_CAPTURE_POLICY_WAIT,
00688 &frame );
00689
00690 if ( err != DC1394_SUCCESS )
00691 {
00692 fprintf( stderr, "extractImagesColor - cannot dequeue image!\n" );
00693 return;
00694 }
00695
00696
00697
00698 unsigned char* pucGrabBuffer = frame->image;
00699
00700
00701 dc1394_deinterlace_rgb( pucGrabBuffer,
00702 pucDeInterleaved,
00703 stereoCamera->nCols,
00704 3*stereoCamera->nRows );
00705
00706
00707 dc1394_bayer_decoding_8bit( pucDeInterleaved,
00708 pucRGB,
00709 stereoCamera->nCols,
00710 3*stereoCamera->nRows,
00711 stereoCamera->bayerTile,
00712 bayerMethod );
00713
00714
00715
00716
00717 dc1394_deinterlace_green( pucRGB, pucGreen, stereoCamera->nCols, 9*stereoCamera->nRows );
00718
00719
00720
00721 int iOneBufferPixels = stereoCamera->nRows * stereoCamera->nCols;
00722 *ppucLeftRGB = pucRGB;
00723 *ppucCenterRGB = pucRGB + 3 * iOneBufferPixels;
00724 *ppucRightRGB = pucRGB + 6 * iOneBufferPixels;
00725
00726
00727
00728
00729 pShortInput->inputType = TriInp_RGB;
00730 pShortInput->nrows = stereoCamera->nRows;
00731 pShortInput->ncols = stereoCamera->nCols;
00732 pShortInput->rowinc = stereoCamera->nCols;
00733 pShortInput->u.rgb.red = pucGreen + 2*iOneBufferPixels;
00734 pShortInput->u.rgb.green = pucGreen + iOneBufferPixels;
00735 pShortInput->u.rgb.blue = pShortInput->u.rgb.green;
00736
00737 pWideInput->inputType = TriInp_RGB;
00738 pWideInput->nrows = stereoCamera->nRows;
00739 pWideInput->ncols = stereoCamera->nCols;
00740 pWideInput->rowinc = stereoCamera->nCols;
00741 pWideInput->u.rgb.red = pucGreen + 2*iOneBufferPixels;
00742 pWideInput->u.rgb.green = pucGreen;
00743 pWideInput->u.rgb.blue = pWideInput->u.rgb.green;
00744
00745
00746
00747
00748
00749
00750 dc1394_capture_enqueue( stereoCamera->camera, frame );
00751 return;
00752 }
00753
00754
00755
00756
00757
00758
00759
00760 void
00761 extractImagesMonoXB3( PGRStereoCamera_t* stereoCamera,
00762 unsigned char* pucDeInterleaved,
00763 unsigned char** ppucRightMono8,
00764 unsigned char** ppucLeftMono8,
00765 unsigned char** ppucCenterMono8,
00766 TriclopsInput* pShortInput,
00767 TriclopsInput* pWideInput )
00768 {
00769
00770 dc1394error_t err;
00771
00772 dc1394video_frame_t* frame;
00773 err = dc1394_capture_dequeue( stereoCamera->camera,
00774 DC1394_CAPTURE_POLICY_WAIT,
00775 &frame );
00776 if ( err != DC1394_SUCCESS )
00777 {
00778 fprintf( stderr, "extractImagesColor - cannot dequeue image!\n" );
00779 return;
00780 }
00781
00782 unsigned char* pucGrabBuffer = frame->image;
00783
00784 unsigned char* right;
00785 unsigned char* left;
00786 unsigned char* center;
00787
00788 dc1394_deinterlace_rgb( pucGrabBuffer,
00789 pucDeInterleaved,
00790 stereoCamera->nCols,
00791 3*stereoCamera->nRows );
00792
00793
00794
00795 left = pucDeInterleaved;
00796 center = pucDeInterleaved + stereoCamera->nRows * stereoCamera->nCols;
00797 right = pucDeInterleaved + 2 * stereoCamera->nRows * stereoCamera->nCols;
00798
00799 *ppucRightMono8 = right;
00800 *ppucLeftMono8 = left;
00801 *ppucCenterMono8 = center;
00802
00803 pShortInput->inputType = TriInp_RGB;
00804 pShortInput->nrows = stereoCamera->nRows;
00805 pShortInput->ncols = stereoCamera->nCols;
00806 pShortInput->rowinc = stereoCamera->nCols;
00807 pShortInput->u.rgb.red = right;
00808 pShortInput->u.rgb.green = center;
00809 pShortInput->u.rgb.blue = center;
00810
00811 pWideInput->inputType = TriInp_RGB;
00812 pWideInput->nrows = stereoCamera->nRows;
00813 pWideInput->ncols = stereoCamera->nCols;
00814 pWideInput->rowinc = stereoCamera->nCols;
00815 pWideInput->u.rgb.red = right;
00816 pWideInput->u.rgb.green = left;
00817 pWideInput->u.rgb.blue = left;
00818
00819
00820 dc1394_capture_enqueue( stereoCamera->camera, frame );
00821
00822 return;
00823 }
00824
00825 void
00826 extractImagesColorXB3( PGRStereoCamera_t* stereoCamera,
00827 dc1394bayer_method_t bayerMethod,
00828 unsigned char* pucDeInterleaved,
00829 unsigned char* pucRGB,
00830 unsigned char* pucGreen,
00831 unsigned char** ppucRightRGB,
00832 unsigned char** ppucLeftRGB,
00833 unsigned char** ppucCenterRGB)
00834 {
00835
00836 dc1394error_t err;
00837 dc1394video_frame_t* frame;
00838
00839 err = dc1394_capture_dequeue( stereoCamera->camera,
00840 DC1394_CAPTURE_POLICY_WAIT,
00841 &frame );
00842
00843 if ( err != DC1394_SUCCESS )
00844 {
00845 fprintf( stderr, "extractImagesColor - cannot dequeue image!\n" );
00846 return;
00847 }
00848
00849
00850 unsigned char* pucGrabBuffer = frame->image;
00851
00852
00853
00854 dc1394_deinterlace_rgb( pucGrabBuffer,
00855 pucDeInterleaved,
00856 stereoCamera->nCols,
00857 3*stereoCamera->nRows );
00858
00859
00860
00861
00862 dc1394_bayer_decoding_8bit( pucDeInterleaved,
00863 pucRGB,
00864 stereoCamera->nCols,
00865 3*stereoCamera->nRows,
00866 stereoCamera->bayerTile,
00867 bayerMethod );
00868
00869
00870
00871
00872
00873 dc1394_deinterlace_green( pucRGB, pucGreen, stereoCamera->nCols, 9*stereoCamera->nRows );
00874
00875
00876
00877
00878 int iOneBufferPixels = stereoCamera->nRows * stereoCamera->nCols;
00879 *ppucLeftRGB = pucRGB;
00880 *ppucCenterRGB = pucRGB + 3 * iOneBufferPixels;
00881 *ppucRightRGB = pucRGB + 6 * iOneBufferPixels;
00882
00883
00884
00885 dc1394_capture_enqueue( stereoCamera->camera, frame );
00886
00887 return;
00888 }
00892