Scanner::Scanner(bool webCam)
{
	web=webCam;
	proj=new Projector(proj_w,proj_h);
	whiteImg = cv::Mat::ones(proj_h,proj_w,CV_8U)*255;
	EdsInitializeSDK();
}
예제 #2
0
void initializeSDK() {
	EdsError err = EdsInitializeSDK();
	if (err != EDS_ERR_OK) {
		handleErrorCode(err);
	}
}
    //---------------------------------------------------------------------
    bool CanonCameraWrapper::setup(int cameraID){
        if( theCamera != NULL || theCameraList != NULL){
            destroy();
        }

        EdsError err = EDS_ERR_OK;
        EdsUInt32 cameraCount = 0 ;

        err = EdsInitializeSDK();

        if(err != EDS_ERR_OK){
           printf("Couldn't open sdk!\n");
            return false;
        }else{
            printf("Opening the sdk\n");
            sdkRef++;
        }
		
		ofSleepMillis(3000);

        // Initialize
        // Get the camera list
        err = EdsGetCameraList(&theCameraList);

        // Get the number of cameras.
        if( err == EDS_ERR_OK ){
            err = EdsGetChildCount( theCameraList, &cameraCount );
            if ( cameraCount == 0 ){
                err = EDS_ERR_DEVICE_NOT_FOUND;
                printf("No devices found!\n");
                return false;
            }
        }

        // Get the camera
        if ( err == EDS_ERR_OK ){
            if (cameraID >= cameraCount){
                printf("No camera of id %i exists - number of cameras is %i\n", cameraID, cameraCount);
                return false;
            }

            printf("We are opening camera %i!\n", cameraID);

            err = EdsGetChildAtIndex( theCameraList , cameraID , &theCamera );
			
			//Release camera list
			if(theCameraList != NULL){
				EdsRelease(theCameraList);
			}
			
            if(err == EDS_ERR_OK){
                printf("We are connected!\n");
                state = CAMERA_READY;
                //return true;
            }else{
                printf("We are not connected!\n");
                state = CAMERA_UNKNOWN;
                return false;
            }
			
            registerCallback();		
			return true;			
        }
    }
예제 #4
0
int CanonEDCamera::Initialize()
{
   EdsError err = EDS_ERR_OK; 
    
   // Initialize SDK 
   err = EdsInitializeSDK(); 
   if(err == EDS_ERR_OK) 
   { 
     isSDKLoaded_ = true; 
   } 
    
   // Get first camera 
   if(err == EDS_ERR_OK) 
   { 
      err = getFirstCamera (&camera_); 
   } 

   if (err == EDS_ERR_DEVICE_NOT_FOUND)
      return ERR_NO_CAMERA;
    

   // event handlers are static functions that need a reference to this camera object to function
   // provide that static ref here.  This approach will fail with multiple cameras.  In that case, 
   // consider making a map with cameras and references to our CanonEDCamera objects
   g_Self = this;

   // Set event handler 
   if(err == EDS_ERR_OK) 
   { 
      err = EdsSetObjectEventHandler(camera_,  kEdsObjectEvent_All, &CanonEDCamera::handleObjectEvent,  NULL); 
   } 
    
   // Set event handler 
   if(err == EDS_ERR_OK) 
   { 
      err = EdsSetPropertyEventHandler(camera_,  kEdsPropertyEvent_All, &CanonEDCamera::handlePropertyEvent,  NULL); 
   } 
    
   // Set event handler 
   if(err == EDS_ERR_OK) 
   { 
      err = EdsSetCameraStateEventHandler(camera_,  kEdsStateEvent_All, &CanonEDCamera::handleStateEvent,  NULL); 
   } 

   if(err == EDS_ERR_OK) 
   { 
      err = EdsOpenSession(camera_); 
   } 
     
   // Camera name
   if (err == EDS_ERR_OK)
   {
      EdsDeviceInfo  deviceInfo;
      err = EdsGetDeviceInfo(camera_, &deviceInfo);
      if (err == EDS_ERR_OK)
      {
         std::ostringstream os;
         os << "Canon SLR device subtype: " << deviceInfo.deviceSubType;
         LogMessage(os.str().c_str());
         if (deviceInfo.deviceSubType == 0)
            isLegacy_ = true;
         cameraModel_ = deviceInfo.szDeviceDescription;
         int nRet = CreateProperty("Model", cameraModel_.c_str(), MM::String, true);
         if (nRet != DEVICE_OK)
            return nRet;
      }

      // Set and Get various camera properties

      // lock the UI before setting properties - only needed on legacy cameras
      if (isLegacy_)
         EdsSendStatusCommand (camera_,  kEdsCameraStatusCommand_UILock, 0);
      EdsSaveTo toPC = kEdsSaveTo_Host;
      err = EdsSetPropertyData(camera_,  kEdsPropID_SaveTo, 0 , sizeof(EdsSaveTo),  &toPC);
      if (isLegacy_)
         EdsSendStatusCommand (camera_, kEdsCameraStatusCommand_UIUnLock, 0);
   }

   if (err == EDS_ERR_OK)
   {
      CPropertyAction* pAct = new CPropertyAction(this, &CanonEDCamera::OnBinning);
      int nRet = CreateProperty(MM::g_Keyword_Binning, "1", MM::Integer, false, pAct);
      if (nRet != DEVICE_OK)
         return nRet;
   }

   if (err == EDS_ERR_OK)
   {
      return DEVICE_OK;
   }

   std::ostringstream os;
   os << "Error during initialization: " << std::hex << err;
   LogMessage(os.str().c_str());

   return err;
}
예제 #5
0
boolean connectToFirstCamera(){
	
	EdsError err = EDS_ERR_OK;

	// Initialize SDK
	err = EdsInitializeSDK();
	if ( err == EDS_ERR_OK )
		isSDKLoaded = true;


/*	// Get first camera
	if(err == EDS_ERR_OK)
	{
		err = getFirstCamera();
	}*/

	EdsCameraListRef cameraList = NULL;
	EdsUInt32 count = 0;

	// Get camera list
	err = EdsGetCameraList(&cameraList);

	// Get number of cameras
	if(err == EDS_ERR_OK)
	{
		err = EdsGetChildCount(cameraList, &count);
		if(count == 0)
		{
			err = EDS_ERR_DEVICE_NOT_FOUND;
		}
	}

	// Get first camera retrieved
	if(err == EDS_ERR_OK)
	{
		err = EdsGetChildAtIndex(cameraList , 0 , &camera);
	}

	// Release camera list
	if(cameraList != NULL)
	{
		EdsRelease(cameraList);
		cameraList = NULL;
	}

	//Open Session
	if(err == EDS_ERR_OK)
	{
		err = EdsOpenSession(camera);
	}

	//Set save to host
	if (err == EDS_ERR_OK ) {
		EdsUInt32 wkSaveTo = kEdsSaveTo_Host ;
		do {
			err = EdsSetPropertyData ( camera, kEdsPropID_SaveTo, 
				0, 4, (void*)&wkSaveTo ) ;
			if (err != EDS_ERR_OK) {
				std::cout << "warning: camera busy, waiting..." << std::endl;
				std::flush(std::cout);
				Sleep(100);
			}
		} while (err != EDS_ERR_OK);
	}

	// Set host capacity
	EdsCapacity capacity = {0x7FFFFFFF, 0x1000, 1};
	err = EdsSetCapacity ( camera, capacity );

	return err == EDS_ERR_OK;
}