Beispiel #1
0
//=============================================================================
// extractImagesMono()
//
// De-interleave the stereo images into single images
// Construct a TriclopsInput for stereo processing from these images.
//
void
extractImagesMono( PGRStereoCamera_t* 	stereoCamera, 
		   unsigned char* 	pucDeInterleaved,
		   unsigned char** 	ppucRightMono8,
		   unsigned char** 	ppucLeftMono8,
		   unsigned char** 	ppucCenterMono8) 
{

   dc1394error_t err;
   // RC7
   dc1394video_frame_t* frame;
   err = dc1394_capture_dequeue( stereoCamera->camera,
				 DC1394_CAPTURE_POLICY_WAIT,
				 &frame );
   if ( err != DC1394_SUCCESS )
   {
      fprintf( stderr, "extractImagesColor - cannot dequeue image!\n" );
      return;
   }

   unsigned char* pucGrabBuffer = frame->image;

   unsigned char* right;
   unsigned char* left;
   unsigned char* center;
   if ( stereoCamera->nBytesPerPixel == 2 )
   {
      // de-interlace the 16 bit data into 2 mono images
      dc1394_deinterlace_stereo( pucGrabBuffer,
				 pucDeInterleaved,
				 stereoCamera->nCols,
				 2*stereoCamera->nRows );
      right = pucDeInterleaved;
      left  = pucDeInterleaved + stereoCamera->nRows * stereoCamera->nCols;
      center= left;
   }
   else
   {
      dc1394_deinterlace_rgb( pucGrabBuffer,
			      pucDeInterleaved,
			      stereoCamera->nCols,
			      3*stereoCamera->nRows );

      // NOTE: this code needs to be double checked.
      // Currently 3-bytes-per-pixel is not activatable in this example
      right 	= pucDeInterleaved;
      center  	= pucDeInterleaved + stereoCamera->nRows * stereoCamera->nCols;
      left	= pucDeInterleaved + 2 * stereoCamera->nRows * stereoCamera->nCols;
   }
      
   *ppucRightMono8 	= right;
   *ppucLeftMono8 	= left;
   *ppucCenterMono8 	= center;

   // return buffer for use
   dc1394_capture_enqueue( stereoCamera->camera, frame );

   return;
}
Beispiel #2
0
void
extractImagesColorXB3( PGRStereoCamera_t* 	 stereoCamera, 
		       dc1394bayer_method_t bayerMethod,
		       unsigned char* 	pucDeInterleaved,
		       unsigned char* 	pucRGB,
		       unsigned char* 	pucGreen,
		       unsigned char** 	ppucRightRGB,
		       unsigned char** 	ppucLeftRGB,
		       unsigned char** 	ppucCenterRGB) 
{

   dc1394error_t err;
   dc1394video_frame_t* frame;
   err = dc1394_capture_dequeue( stereoCamera->camera,
				 DC1394_CAPTURE_POLICY_WAIT,
				 &frame );
   if ( err != DC1394_SUCCESS )
   {
      fprintf( stderr, "extractImagesColor - cannot dequeue image!\n" );
      return;
   }

   unsigned char* pucGrabBuffer = frame->image;

   dc1394_deinterlace_rgb( pucGrabBuffer,
			   pucDeInterleaved,
			   stereoCamera->nCols,
			   3*stereoCamera->nRows );
   // extract color from the bayer tile image
   // note: this will alias colors on the top and bottom rows
   dc1394_bayer_decoding_8bit( pucDeInterleaved,
			       pucRGB,
			       stereoCamera->nCols,
			       3*stereoCamera->nRows,
			       stereoCamera->bayerTile,
			       bayerMethod );
   // now deinterlace the RGB Buffer
   dc1394_deinterlace_green( pucRGB,
			     pucGreen,
			     stereoCamera->nCols,
			     9*stereoCamera->nRows );
   // NOTE: this code needs to be double checked.
   // Currently 3-bytes-per-pixel is not activatable in this example
   int iOneBufferPixels = stereoCamera->nRows * stereoCamera->nCols;
   *ppucLeftRGB 	= pucRGB;
   *ppucCenterRGB 	= pucRGB + 3 * iOneBufferPixels;
   *ppucRightRGB 	= pucRGB + 6 * iOneBufferPixels;
      

   // return buffer for use
   dc1394_capture_enqueue( stereoCamera->camera, frame );
   return;
}
Beispiel #3
0
//=============================================================================
// extractImagesColor()
//
// De-interleave the stereo images into single bayer patterns.
// De-bayer those images into color images.
// Construct a TriclopsInput for stereo processing from these images.
//
void
extractImagesColor( PGRStereoCamera_t* 	 stereoCamera, 
		    dc1394bayer_method_t bayerMethod,
		    unsigned char* 	 pucDeInterleaved,
		    unsigned char* 	 pucRGB,
		    unsigned char* 	 pucGreen,
		    unsigned char** 	 ppucRightRGB,
		    unsigned char** 	 ppucLeftRGB,
		    unsigned char** 	 ppucCenterRGB) 
{

   dc1394error_t err;
   dc1394video_frame_t* frame;
   err = dc1394_capture_dequeue( stereoCamera->camera,
				 DC1394_CAPTURE_POLICY_WAIT,
				 &frame );
   if ( err != DC1394_SUCCESS )
   {
      fprintf( stderr, "extractImagesColor - cannot dequeue image!\n" );
      return;
   }

   unsigned char* pucGrabBuffer = frame->image;

   if ( stereoCamera->nBytesPerPixel == 2 )
   {
      // de-interlace the 16 bit data into 2 bayer tile pattern images
      dc1394_deinterlace_stereo( pucGrabBuffer,
				 pucDeInterleaved,
				 stereoCamera->nCols,
				 2*stereoCamera->nRows );
      // extract color from the bayer tile image
      // note: this will alias colors on the top and bottom rows
      dc1394_bayer_decoding_8bit( pucDeInterleaved,
				  pucRGB,
				  stereoCamera->nCols,
				  2*stereoCamera->nRows,
				  stereoCamera->bayerTile,
				  bayerMethod );
      // now deinterlace the RGB Buffer to extract the green channel
      // The green channel is a quick and dirty approximation to the mono
      // equivalent of the image and can be used for stereo processing
      dc1394_deinterlace_green( pucRGB,
				pucGreen,
				stereoCamera->nCols,
				6*stereoCamera->nRows );
      *ppucRightRGB 	= pucRGB;
      *ppucLeftRGB 	= pucRGB + 3 * stereoCamera->nRows * stereoCamera->nCols;
      *ppucCenterRGB	= *ppucLeftRGB;
   }
   else
   {
      dc1394_deinterlace_rgb( pucGrabBuffer,
			      pucDeInterleaved,
			      stereoCamera->nCols,
			      3*stereoCamera->nRows );
      // extract color from the bayer tile image
      // note: this will alias colors on the top and bottom rows
      dc1394_bayer_decoding_8bit( pucDeInterleaved,
				  pucRGB,
				  stereoCamera->nCols,
				  3*stereoCamera->nRows,
				  stereoCamera->bayerTile,
				  bayerMethod );
      // now deinterlace the RGB Buffer
      dc1394_deinterlace_green( pucRGB,
				pucGreen,
				stereoCamera->nCols,
				9*stereoCamera->nRows );
      // NOTE: this code needs to be double checked.
      // Currently 3-bytes-per-pixel is not activatable in this example
      *ppucRightRGB 	= pucRGB;
      *ppucCenterRGB 	= pucRGB + 3 * stereoCamera->nRows * stereoCamera->nCols;
      *ppucLeftRGB 	= pucRGB + 6 * stereoCamera->nRows * stereoCamera->nCols;
   }
      
   // return buffer for use
   dc1394_capture_enqueue( stereoCamera->camera, frame );
   return;
}
//=============================================================================
// extractImagesMono()
//
// De-interleave the stereo images into single images
// Construct a TriclopsInput for stereo processing from these images.
//
void
extractImagesMonoXB3( PGRStereoCamera_t* 	stereoCamera, 
		      unsigned char* 	pucDeInterleaved,
		      unsigned char** 	ppucRightMono8,
		      unsigned char** 	ppucLeftMono8,
		      unsigned char** 	ppucCenterMono8,
		      TriclopsInput*  	pShortInput,
		      TriclopsInput* 	pWideInput ) 
{

   dc1394error_t err;
   // RC7
   dc1394video_frame_t* frame;
   err = dc1394_capture_dequeue( stereoCamera->camera,
				 DC1394_CAPTURE_POLICY_WAIT,
				 &frame );
   if ( err != DC1394_SUCCESS )
   {
      fprintf( stderr, "extractImagesColor - cannot dequeue image!\n" );
      return;
   }

   unsigned char* pucGrabBuffer = frame->image;

   unsigned char* right;
   unsigned char* left;
   unsigned char* center;

   dc1394_deinterlace_rgb( pucGrabBuffer,
			   pucDeInterleaved,
			   stereoCamera->nCols,
			   3*stereoCamera->nRows );
   
   // NOTE: this code needs to be double checked.
   // Currently 3-bytes-per-pixel is not activatable in this example
   left 	= pucDeInterleaved;
   center  	= pucDeInterleaved + stereoCamera->nRows * stereoCamera->nCols;
   right	= pucDeInterleaved + 2 * stereoCamera->nRows * stereoCamera->nCols;
      
   *ppucRightMono8 	= right;
   *ppucLeftMono8 	= left;
   *ppucCenterMono8 	= center;

   pShortInput->inputType 	= TriInp_RGB;
   pShortInput->nrows		= stereoCamera->nRows;
   pShortInput->ncols		= stereoCamera->nCols;
   pShortInput->rowinc		= stereoCamera->nCols;
   pShortInput->u.rgb.red   	= right;
   pShortInput->u.rgb.green 	= center;
   pShortInput->u.rgb.blue  	= center;

   pWideInput->inputType 	= TriInp_RGB;
   pWideInput->nrows		= stereoCamera->nRows;
   pWideInput->ncols		= stereoCamera->nCols;
   pWideInput->rowinc		= stereoCamera->nCols;
   pWideInput->u.rgb.red   	= right;
   pWideInput->u.rgb.green 	= left;
   pWideInput->u.rgb.blue  	= left;

   // return buffer for use
   dc1394_capture_enqueue( stereoCamera->camera, frame );

   return;
}