PGRBitmapTriclops::PGRBitmapTriclops( 
                                     int              iWidth, 
                                     int              iHeight, 
                                     int              iBitsPerPixel, 
				     bool	      bOwnsData,
                                     unsigned char*   pImageData )
{
   assert( iBitsPerPixel % 8 == 0 );

   m_iBitsPerPixel = iBitsPerPixel;
   m_iWidth = iWidth;
   m_iHeight = iHeight;
   m_bOwnsData = bOwnsData;

   if( m_bOwnsData )
   {
      m_pData = new unsigned char[ iWidth * iHeight * ( iBitsPerPixel / 8 ) ];
      memset( m_pData, 0, iWidth * iHeight * ( iBitsPerPixel / 8 ) );
   }
   else
   {
      m_bOwnsData = FALSE;
      m_pData = pImageData;
   }

   initBitmapInfo();
}
Ejemplo n.º 2
0
BOOL 
CTimeSliceDoc::OnNewDocument()
{
   if ( !CDocument::OnNewDocument() )
   {
      return FALSE;
   }

   m_eventGrabFinished = ::CreateEvent( NULL, FALSE, FALSE, NULL );

   FlyCaptureError   error;
   unsigned int      uiCamera;

   //
   // Initialize all the cameras on the bus in order of serial number.
   //
   FlyCaptureInfoEx arCameras[ MAX_CAMERAS ];
   m_uiNumCameras = MAX_CAMERAS;
   error = ::flycaptureBusEnumerateCamerasEx( arCameras, &m_uiNumCameras );
   _CHECK_ERROR( "flycaptureBusEnumerateCamerasEx()", error );

   if( m_uiNumCameras == 0 )
   {
      AfxMessageBox( "No cameras were detected on the bus, exiting" );
      return FALSE;
   }

   //
   // Sort the serial numbers, remembering the bus order.
   //
   std::list< unsigned long > listCameras;
   for( uiCamera = 0; uiCamera < m_uiNumCameras; uiCamera++ )
   {
      listCameras.push_back( arCameras[ uiCamera ].SerialNumber );
   }

   listCameras.sort();

   //
   // Initialize the cameras in serial-number order.
   //
   for( uiCamera = 0; uiCamera < m_uiNumCameras; uiCamera++ )
   {
      CameraInfo&  camera = m_arCameraInfo[ uiCamera ];

      error = ::flycaptureCreateContext( &camera.m_context );
      _CHECK_ERROR( "flycaptureCreateContext()", error );

      unsigned int uiBusIndex;
      for( uiBusIndex = 0; uiBusIndex < m_uiNumCameras; uiBusIndex++ )
      {
         if( arCameras[ uiBusIndex ].SerialNumber == listCameras.front() )
         {
            break;
         }
      }
      ASSERT( uiBusIndex != m_uiNumCameras );

      error = ::flycaptureInitializePlus(
         camera.m_context, uiBusIndex, NUM_BUFFERS, NULL );
      _CHECK_ERROR( "flycaptureInitializePlus()", error );

      listCameras.pop_front();

      error = ::flycaptureGetCameraInfo(
	 camera.m_context, &camera.m_info   );
      _CHECK_ERROR( "flycaptureGetCameraInfo()", error );

      camera.m_uiPrevSeqNum = 0;

      //
      // Set a default colour processing method.
      //
      error = ::flycaptureSetColorProcessingMethod(
	 camera.m_context, COLOUR_PROCESSING_METHOD );
      _CHECK_ERROR( "flycaptureSetColorProcessingMethod()", error );
   }

   //
   // Configure grab and pan values based on camera speed.
   //
   if( m_uiNumCameras <= 4 )   
   {
      //
      // 30 Hz. 
      //
      m_iFramesPerCameraPanning  = 4;
      m_iFramesForEndCamera      = 4;
      m_iFramesAtEnd		 = 50;
      m_iNumberOfPanCycles	 = 2;
      m_iInitialBufferedImages	 = 15;  // half a second.
   }
   else
   {
      //
      // 15 Hz.
      //
      m_iFramesPerCameraPanning  = 2;
      m_iFramesForEndCamera      = 2;
      m_iFramesAtEnd		 = 20;
      m_iNumberOfPanCycles	 = 2;
      m_iInitialBufferedImages	 = 7;   // half a second.
   }

   m_iExtraBuffers = m_iFramesForEndCamera + m_iFramesAtEnd;

   //
   // Create extra view windows
   //
   ((CTimeSliceApp*)AfxGetApp())->setViews( m_uiNumCameras );

   //
   // Initialize the GUI contexts for all of the cameras.
   //
   for( uiCamera = 0; uiCamera < m_uiNumCameras; uiCamera++ )
   {
      CameraGUIError guierror;
      CameraInfo&    cameraInfo = m_arCameraInfo[ uiCamera ];

      guierror = ::pgrcamguiCreateContext( &cameraInfo.m_guicontext );
      ASSERT( error == PGRCAMGUI_OK );

      guierror = ::pgrcamguiCreateSettingsDialog(
	 cameraInfo.m_guicontext,
	 PGRCAMGUI_TYPE_PGRFLYCAPTURE,
	 (GenericCameraContext)cameraInfo.m_context );
      ASSERT( error == PGRCAMGUI_OK );
   }

   //
   // Call helper functions.
   //
   initBitmapInfo();
   initTempImages();
   initProcessedImages();
   resizeExtraImageBuffers( MIN_BGR_BUFFER_SIZE );
   mostNumberOfCamerasOnASingleBus();
   readTweakValues();

   m_cameraInfoTimeSlice = m_arCameraInfo[ 0 ];

   VERIFY( m_dialogScrollMode.Create( IDD_DIALOG_SCROLLMODE ) );
   m_dialogScrollMode.m_pDoc = this;
   allocateScrollModeBuffers( MIN_BGR_BUFFER_SIZE );

   //
   // Start up grab thread.
   //
   m_bContinueGrab = true;
   ::_beginthread( threadGrab, 0, this  );

   return TRUE;
}