gphoto2pp
A C++ Wrapper for libgphoto2
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
gphoto2pp::CameraWrapper Class Reference

#include <camera_wrapper.hpp>

Public Member Functions

 CameraWrapper ()
 Create a Camera without prior using autoDetect static method. This method will automatically choose the first camera it finds.
 CameraWrapper (std::string const &model, std::string const &port)
 Connects and initializes using the provided model and port.
 ~CameraWrapper ()
 CameraWrapper (CameraWrapper &&other)
CameraWrapperoperator= (CameraWrapper &&other)
 CameraWrapper (const CameraWrapper &other)
CameraWrapperoperator= (CameraWrapper const &other)
std::string getSummary () const
 Gets the complete summary of the currently connected camera. This summary indicates numerous details about make, model, and configurable abilities.
std::string getModel () const
 Gets the camera model currently connected to.
std::string getPort () const
 Gets the computer port currently connected to the camera.
CameraFileWrapper capturePreview ()
 Captures a preview image from the camera. This capture type might not be supported by all cameras (requires a live view/mirror lockup mode for continuous captures). The image does not persist on the camera.
CameraFilePathWrapper capture (CameraCaptureTypeWrapper const &captureType)
 Captures a file from the camera.
void triggerCapture ()
 Triggers the camera to take a picture (similar to a remote shutter release). The image is saved to the camera's portable storage for retrieval later.
WindowWidget getConfig () const
 Queries all the properties/abilities on the camera and compiles them in a Widget N-way tree hierarchy.
void setConfig (CameraWidgetWrapper const &cameraWidget)
 Sets the widgets to the provided settings. It's important to note, that if camera settings change (manually by physical interaction), and then you call this method with the old settings, it will change the camera back to the old settings. It's best practice to query the camera, change the settings, and then immediately set the config again.
CameraListWrapper folderListFiles (std::string const &folder) const
 Lists all files in the provided folder.
CameraListWrapper folderListFolders (std::string const &folder) const
 Lists all folders in the provided folder.
void folderDeleteAll (std::string const &folder)
 Delete all files in the provided folder.
void folderPutFile (std::string const &folder, std::string const &fileName, CameraFileTypeWrapper const &fileType, CameraFileWrapper cameraFile)
 Write a file in the provided folder.
void folderMakeDir (std::string const &folder, std::string const &name)
 Make a new folder in the provided directory.
void folderRemoveDir (std::string const &folder, std::string const &name)
 Remove a directory from the provided folder.
CameraFileWrapper fileGet (std::string const &folder, std::string const &fileName, CameraFileTypeWrapper const &fileType) const
 Retrieve a file from the camera.
void fileDelete (std::string const &folder, std::string const &fileName) const
 Delete a file from the camera.
observer::Registration subscribeToCameraEvent (CameraEventTypeWrapper const &event, std::function< void(const CameraFilePathWrapper &, const std::string &)> func)
 Helper method used to subscribe to Camera Wait For events. This method should be used to setup all the callbacks necessary before calling startListeningForEvents. Provide your callback method with lambdas or static/instance methods (use std::bind).
bool startListeningForEvents ()
 Starts monitoring the camera events You must subscribe to at least one event type and then perform some action on the camera to see this in action.
void stopListeningForEvents ()
 Signals the thread to stop listening. If there is no thread, it leaves the method immediately, if there is a thread running, it is a blocking call which will not return until the thread exits.

Constructor & Destructor Documentation

gphoto2pp::CameraWrapper::CameraWrapper ( )

Create a Camera without prior using autoDetect static method. This method will automatically choose the first camera it finds.

gphoto2pp::CameraWrapper::CameraWrapper ( std::string const &  model,
std::string const &  port 
)

Connects and initializes using the provided model and port.

gphoto2pp::CameraWrapper::~CameraWrapper ( )
gphoto2pp::CameraWrapper::CameraWrapper ( CameraWrapper &&  other)
gphoto2pp::CameraWrapper::CameraWrapper ( const CameraWrapper other)

Member Function Documentation

CameraFilePathWrapper gphoto2pp::CameraWrapper::capture ( CameraCaptureTypeWrapper const &  captureType)

Captures a file from the camera.

Parameters
[in]captureTypeof file to retrieve from the camera
Returns
the file path
Note
Direct wrapper for gp_camera_capture(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
CameraFileWrapper gphoto2pp::CameraWrapper::capturePreview ( )

Captures a preview image from the camera. This capture type might not be supported by all cameras (requires a live view/mirror lockup mode for continuous captures). The image does not persist on the camera.

Returns
the image captured
Note
Direct wrapper for gp_camera_capture_preview(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraWrapper::fileDelete ( std::string const &  folder,
std::string const &  fileName 
) const

Delete a file from the camera.

Parameters
[in]foldercontaining the file to delete
[in]fileNameof the file to delete
Note
Direct wrapper for gp_camera_file_get(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
CameraFileWrapper gphoto2pp::CameraWrapper::fileGet ( std::string const &  folder,
std::string const &  fileName,
CameraFileTypeWrapper const &  fileType 
) const

Retrieve a file from the camera.

Parameters
[in]foldercontaining the file to get
[in]fileNameof the file to retrieve
[in]fileTypeof the file to retrieve
Returns
the file
Note
Direct wrapper for gp_camera_file_get(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraWrapper::folderDeleteAll ( std::string const &  folder)

Delete all files in the provided folder.

Parameters
[in]folderto delete all files
Note
Direct wrapper for gp_camera_folder_delete_all(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
CameraListWrapper gphoto2pp::CameraWrapper::folderListFiles ( std::string const &  folder) const

Lists all files in the provided folder.

Parameters
[in]folderto list all files in
Returns
the list of files
Note
Direct wrapper for gp_camera_folder_list_files(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
CameraListWrapper gphoto2pp::CameraWrapper::folderListFolders ( std::string const &  folder) const

Lists all folders in the provided folder.

Parameters
[in]folderto list all folders in
Returns
the list of folders
Note
Direct wrapper for gp_camera_folder_list_folders(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraWrapper::folderMakeDir ( std::string const &  folder,
std::string const &  name 
)

Make a new folder in the provided directory.

Parameters
[in]folderto make the new folder in
[in]namefor the new folder
Note
Direct wrapper for gp_camera_folder_make_dir(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraWrapper::folderPutFile ( std::string const &  folder,
std::string const &  fileName,
CameraFileTypeWrapper const &  fileType,
CameraFileWrapper  cameraFile 
)

Write a file in the provided folder.

Parameters
[in]folderto write the new file in
[in]fileNamefor the new file to be written
[in]fileTypefor the new file to be written
[in]cameraFilecontains the new file to be written to the folder
Note
Direct wrapper for gp_camera_folder_put_file(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraWrapper::folderRemoveDir ( std::string const &  folder,
std::string const &  name 
)

Remove a directory from the provided folder.

Parameters
[in]foldercontaining the folder to remove
[in]nameof the folder to remove
Note
Direct wrapper for gp_camera_folder_remove_dir(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
WindowWidget gphoto2pp::CameraWrapper::getConfig ( ) const

Queries all the properties/abilities on the camera and compiles them in a Widget N-way tree hierarchy.

Returns
the Root widget (which will always be of type Window Widget)
Note
Direct wrapper for gp_camera_get_config(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
std::string gphoto2pp::CameraWrapper::getModel ( ) const

Gets the camera model currently connected to.

Returns
the model name
std::string gphoto2pp::CameraWrapper::getPort ( ) const

Gets the computer port currently connected to the camera.

Returns
the port name
std::string gphoto2pp::CameraWrapper::getSummary ( ) const

Gets the complete summary of the currently connected camera. This summary indicates numerous details about make, model, and configurable abilities.

Returns
the summary
Note
Direct wrapper for gp_camera_get_summary(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
CameraWrapper& gphoto2pp::CameraWrapper::operator= ( CameraWrapper &&  other)
CameraWrapper& gphoto2pp::CameraWrapper::operator= ( CameraWrapper const &  other)
void gphoto2pp::CameraWrapper::setConfig ( CameraWidgetWrapper const &  cameraWidget)

Sets the widgets to the provided settings. It's important to note, that if camera settings change (manually by physical interaction), and then you call this method with the old settings, it will change the camera back to the old settings. It's best practice to query the camera, change the settings, and then immediately set the config again.

Parameters
[in]cameraWidgetto traverse and write all settings to the camera
Returns
the Root widget (which will always be of type Window Widget)
Note
Direct wrapper for gp_camera_set_config(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
bool gphoto2pp::CameraWrapper::startListeningForEvents ( )

Starts monitoring the camera events You must subscribe to at least one event type and then perform some action on the camera to see this in action.

Returns
true if started listening for events, false if already listening to events
void gphoto2pp::CameraWrapper::stopListeningForEvents ( )

Signals the thread to stop listening. If there is no thread, it leaves the method immediately, if there is a thread running, it is a blocking call which will not return until the thread exits.

observer::Registration gphoto2pp::CameraWrapper::subscribeToCameraEvent ( CameraEventTypeWrapper const &  event,
std::function< void(const CameraFilePathWrapper &, const std::string &)>  func 
)

Helper method used to subscribe to Camera Wait For events. This method should be used to setup all the callbacks necessary before calling startListeningForEvents. Provide your callback method with lambdas or static/instance methods (use std::bind).

Event Types:
  • FileAdded
  • FolderAdded
  • CaptureComplete
  • Timeout
  • Unknown
Parameters
[in]eventtype to subscribe to
[in]funccallback which will be called each time the event type is triggered
Note
Helper structure that wraps gp_camera_wait_for_event(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraWrapper::triggerCapture ( )

Triggers the camera to take a picture (similar to a remote shutter release). The image is saved to the camera's portable storage for retrieval later.

Note
Direct wrapper for gp_camera_trigger_capture(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception

The documentation for this class was generated from the following files: