EdsError EDSCALLBACK Camera::handleStateEvent(EdsUInt32 inEvent, EdsUInt32 inParam, EdsVoid* inContext) {
     Camera* c = (Camera*)inContext;
     CameraRef camera = c->shared_from_this();
     switch (inEvent) {
         case kEdsStateEvent_WillSoonShutDown:
             if (camera->mHasOpenSession && camera->mShouldKeepAlive) {
                 EdsError error = EdsSendCommand(camera->mCamera, kEdsCameraCommand_ExtendShutDownTimer, 0);
                 if (error != EDS_ERR_OK) {
                     std::cerr << "ERROR - failed to extend shut down timer" << std::endl;
                 }
             }
             break;
         case kEdsStateEvent_Shutdown:
             camera->requestCloseSession();
             // send handler and browser removal notices
             if (camera->mRemovedHandler) {
                 camera->mRemovedHandler(camera);
             }
             CameraBrowser::instance()->removeCamera(camera);
             break;
         default:
             break;
     }
     return EDS_ERR_OK;
 }
Exemple #2
0
void releaseShutter(const EdsCameraRef handle) {
	EdsError errorCode = EdsSendCommand(handle,
										kEdsCameraCommand_PressShutterButton,
										kEdsCameraCommand_ShutterButton_OFF);
	if (errorCode != EDS_ERR_OK) {
		handleErrorCode(errorCode);
	}
}
Exemple #3
0
void pressShutter(const EdsCameraRef handle) {
	EdsError errorCode = EdsSendCommand(handle,
										kEdsCameraCommand_PressShutterButton,
										kEdsCameraCommand_ShutterButton_Completely_NonAF);
	if (errorCode != EDS_ERR_OK) {
		handleErrorCode(errorCode);
	}
}
// MMCamera API
int CanonEDCamera::SnapImage()
{
   EdsError err = EdsSendCommand(camera_, kEdsCameraCommand_TakePicture , 0); 
   if (err != EDS_ERR_OK)
      return EdsToMMError(err);

   return DEVICE_OK;
}
/*
 *  Command to press the shutter button.
 *
 *  Possible values:
 *	kEdsCameraCommand_ShutterButton_OFF
 *	kEdsCameraCommand_ShutterButton_Halfway
 *	kEdsCameraCommand_ShutterButton_Completely
 *	kEdsCameraCommand_ShutterButton_Halfway_NonAF
 *	kEdsCameraCommand_ShutterButton_Completely_NonAF
 */
bool
Controller::shutterCommand( int value )
{
    if( camera->handle() == 0 ) {
	return( false );
    }

    int result = EDS_ERR_OK;

    /*
     *  Retry if camera device is busy.
     */
    do {

	result = EdsSendCommand(
			camera->handle(),
			kEdsCameraCommand_PressShutterButton,
			value );

	/*
	 *  If retry is required, the camera may become unstable if multiple
	 *  commands are issued in succession without an intervening interval.
	 *  So, put a delay in before command is reissued.
	 */
	if( result == EDS_ERR_DEVICE_BUSY ) {
	    emit eventReport( new Event( Event::CameraBusy, 0, "shutter" ) );
	    EdsSendCommand(
		camera->handle(),
		kEdsCameraCommand_PressShutterButton,
		kEdsCameraCommand_ShutterButton_OFF );
	    QCoreApplication::processEvents();
	    Sleep( 500 );	// milliseconds
	}

    } while( result == EDS_ERR_DEVICE_BUSY );

    if( result != EDS_ERR_OK ) {
	emit eventReport( new Event( Event::ShutterFailure, result ) );
    }

    return( result == EDS_ERR_OK );
}
void CanonCamera::captureImg()
{
	EdsError	 err = EDS_ERR_OK;
	do 
	{
		err = EdsSendCommand(camera, kEdsCameraCommand_TakePicture, 0);
		if (err != EDS_ERR_OK)	
			Sleep(500);
	} 
	while (err != EDS_ERR_OK);
}
 EdsError Camera::requestTakePicture() {
     if (!mHasOpenSession) {
         return EDS_ERR_SESSION_NOT_OPEN;
     }
     
     EdsError error = EdsSendCommand(mCamera, kEdsCameraCommand_TakePicture, 0);
     if (error != EDS_ERR_OK) {
         std::cerr << "ERROR - failed to take picture" << std::endl;
     }
     return error;
 }
boolean takeAPicture(const char* filename, void(*cb)(void*)){

	//printf("taking a picture\n");
	if (pictureProgress != CAMERA_RESET) {
		std::cout << "error: camera not reset" << std::endl;
		std::flush(std::cout);
		return false;
	}
	EdsError err = EDS_ERR_OK;
	callback = cb;
	
	// Set event handler
	if(err == EDS_ERR_OK)
	{
		//printf("%s\n", filename);
		strcpy_s(theFileName, 1024, filename);
		//printf("%s\n", theFileName);
		if (camera==NULL) {
			std::cout << "error: camera is null" << std::endl;
			std::flush(std::cout);
			return false;
		}
		err = EdsSetObjectEventHandler(camera, kEdsObjectEvent_All,
			handleObjectEvent, theFileName);
	}

	pictureProgress = CAMERA_BEGIN; // picture started
	err = EdsSendCommand( camera, kEdsCameraCommand_TakePicture, 0);
	//handleObjectEvent( kEdsObjectEvent_DirItemRequestTransfer,NULL, theFileName);
	//printf("done!\n");

	// Run a message loop to guarantee the event handler runs
	MSG msg;
	while(pictureProgress == CAMERA_BEGIN) {        
		GetMessage(&msg, NULL, NULL, NULL);
		TranslateMessage(&msg); 
		DispatchMessage(&msg); 
	}

	return err == EDS_ERR_OK;
}
	bool CanonCameraWrapper::sendCommand( EdsCameraCommand inCommand,  EdsInt32 inParam){
      
		EdsError err = EDS_ERR_OK;
		
		if( preCommand() ){
			err = EdsSendCommand(theCamera, inCommand, inParam);
		
			postCommand();
			
			if(err == EDS_ERR_OK){
				return true;
			}
						
			if(err == EDS_ERR_DEVICE_BUSY){
				printf("CanonCameraWrapper::sendCommand - EDS_ERR_DEVICE_BUSY\n");
				return false;
			}
			
		}
		
		return false;
	}
Exemple #10
0
void snap(const EdsCameraRef handle) {
	EdsError errorCode = EdsSendCommand(handle, kEdsCameraCommand_TakePicture, 0);
	if (errorCode != EDS_ERR_OK) {
		handleErrorCode(errorCode);
	}
}
void
Controller::handleStateEvent(
	EdsStateEvent	inEvent,
	EdsUInt32	inEventData )
{
    switch( inEvent ) {
	/*
	 *  Camera has lost connection to host computer, either because
	 *  it was disconnected by unplugging a cord, opening the
	 *  compact flash compartment, turning the camera off, auto
	 *  shut-off, or by other means.
	 */
	case kEdsStateEvent_Shutdown:
	    if( camera->handle() != 0 ) {
		stopLiveView();
		EdsCloseSession( camera->handle() );
		EdsRelease( camera->handle() );
		camera->setHandle( 0 );
	    }
	    // signal view of change in connection status
	    camera->initialize();
	    emit propertyChanged( kEdsPropID_ProductName, 0 );
	    emit eventReport( new Event( Event::ConnectionLost ) );
	    break;
	/*
	 *  Notifies of whether or not (0/1) there are objects waiting to
	 *  be transferred to the host computer. This is useful when
	 *  ensuring all shot images have been transferred when the
	 *  application is closed. A value of 1 is passed initially
	 *  (whether it is a single shot or a burst of shots to download),
	 *  followed by a 0 when downloading has completed.
	 */
	case kEdsStateEvent_JobStatusChanged:
	    camera->setObjectsWaiting( inEventData );
	    break;
	/*
	 *  Notifies that the camera will shut down after a specific period. 
	 *  Generated only if auto shut-off is set. Exactly when notification
	 *  is issued (that is, the number of seconds until shutdown) varies
	 *  depending on the camera model. If the camera is allowed to shut
	 *  down, the connection will be lost and can only be reestablished
	 *  by pressing the camera's shutter button half-way (or pressing
	 *  menu, disp). To continue operation without having the camera
	 *  shut down, use EdsSendCommand to extend the auto shut-off timer.
	 *  inEventData contains the number of seconds to shutdown.
	 */
	case kEdsStateEvent_WillSoonShutDown:
	    EdsSendCommand( camera->handle(),
			    kEdsCameraCommand_ExtendShutDownTimer,
			    0 );
	    break;
	/*
	 *  As the counterpart event to kEdsStateEvent_WillSoonShutDown,
	 *  this event notifies of updates to the number of seconds until
	 *  a camera shuts down. After the update, the period until shutdown
	 *  is model-dependent. Not all cameras notify of this event.
	 */
	case kEdsStateEvent_ShutDownTimerUpdate:
	    // ignore
	    break;
	/*
	 *  Notifies that a requested release has failed, due to focus
	 *  failure or similar factors: inEventData contains error code.
	 *  Hasn't occurred yet.
	 */
	case kEdsStateEvent_CaptureError:
	    emit eventReport( new Event( Event::CaptureFailure, inEventData ) );
	    break;
	/*
	 *  Notifies of internal SDK errors. If this error event is received,
	 *  the issuing device will probably not be able to continue working
	 *  properly, so cancel the remote connection.
	 */
	case kEdsStateEvent_InternalError:
	    stopLiveView();
	    closeSessionCommand();
	    camera->initialize();
	    // signal view of change in connection status
	    emit propertyChanged( kEdsPropID_ProductName, 0 );
	    emit eventReport( new Event( Event::ConnectionLost ) );
	    break;
	/*
	 *  Not documented and hasn't occurred yet.
	 */
	case kEdsStateEvent_AfResult:
	    emit eventReport(
		new Event( Event::AFResultUnhandled, inEventData ) );
	    break;
	/*
	 *  Notifies of the exposure time during bulb shooting. Events are
	 *  issued in about one-second intervals during bulb shooting. This
	 *  event is only issued when bulb shooting is started on the computer.
	 *  inEventData contains the exposure time in seconds.
	 */
	case kEdsStateEvent_BulbExposureTime:
	    emit eventReport(
		new Event( Event::BulbExposureTime, inEventData ) );
	    break;
    }
}