Documentation
¶
Index ¶
- Constants
- Variables
- func SetIdleFunc(ctx *Context, fun ContextIdleCallback)
- func SetLoggerFunc(fun *LogCallback)
- type Camera
- func (c *Camera) CaptureDownload(buffer io.Writer, leaveOnCamera bool) error
- func (c *Camera) CaptureImage() (*CameraFilePath, error)
- func (c *Camera) CapturePreview(buffer io.Writer) error
- func (camera *Camera) DeleteFile(path *CameraFilePath) error
- func (c Camera) Exit() error
- func (c Camera) Free() error
- func (c *Camera) GetSetting(name string) (*CameraWidget, error)
- func (camera *Camera) ListFiles() ([]CameraStorageInfo, error)
- func (c *Camera) LoadWidgets() error
- func (c *Camera) Reset() error
- type CameraFilePath
- type CameraStorageInfo
- type CameraWidget
- func (w CameraWidget) Children() []*CameraWidget
- func (w *CameraWidget) Find(name string) *CameraWidget
- func (w CameraWidget) Get() (interface{}, error)
- func (w CameraWidget) ID() int
- func (w CameraWidget) Info() string
- func (w CameraWidget) Label() string
- func (w CameraWidget) Name() string
- func (w CameraWidget) Options() ([]string, error)
- func (w CameraWidget) Parent() *CameraWidget
- func (w CameraWidget) ReadOnly() bool
- func (w CameraWidget) Set(input interface{}) error
- func (w CameraWidget) SetInt(input int) error
- func (w *CameraWidget) String() string
- func (w CameraWidget) Type() WidgetType
- type Context
- type ContextIdleCallback
- type ContextLogCallback
- type GphotoError
- type LogCallback
- type WidgetType
Constants ¶
const ( //GPOK means no error GPOK = 0 //Error is a Generic Error Error = -1 //ErrorBadParameters : Bad parameters passed ErrorBadParameters = -2 //ErrorNoMemory : Out of memory ErrorNoMemory = -3 //ErrorLibrary : Error in the camera driver ErrorLibrary = -4 //ErrorUnknownPort : Unknown libgphoto2 port passed ErrorUnknownPort = -5 //ErrorNotSupported : Functionality not supported ErrorNotSupported = -6 //ErrorIO : Generic I/O error ErrorIO = -7 //ErrorFixedLimitExceeded : Buffer overflow of internal structure ErrorFixedLimitExceeded = -8 //ErrorTimeout : Operation timed out ErrorTimeout = -10 //ErrorIOSupportedSerial : Serial ports not supported ErrorIOSupportedSerial = -20 //ErrorIOSupportedUsb : USB ports not supported ErrorIOSupportedUsb = -21 //ErrorIOInit : Error initialising I/O ErrorIOInit = -31 //ErrorIORead : I/O during read ErrorIORead = -34 //ErrorIOWrite : I/O during write ErrorIOWrite = -35 //ErrorIOUpdate : I/O during update of settings ErrorIOUpdate = -37 //ErrorIOSerialSpeed : Specified serial speed not possible. ErrorIOSerialSpeed = -41 //ErrorIOUSBClearHalt : Error during USB Clear HALT ErrorIOUSBClearHalt = -51 //ErrorIOUSBFind : Error when trying to find USB device ErrorIOUSBFind = -52 //ErrorIOUSBClaim : Error when trying to claim the USB device ErrorIOUSBClaim = -53 //ErrorIOLock : Error when trying to lock the device ErrorIOLock = -60 //ErrorHal : Unspecified error when talking to HAL ErrorHal = -70 //ErrorCorruptedData : This error is reported by camera drivers if corrupted data has been received that //can not be automatically handled. Normally, drivers will do everything possible to automatically recover from this error ErrorCorruptedData = -102 //ErrorFileExists : An operation failed because a file existed. This error is reported for example when the user tries to create a file that already exists. ErrorFileExists = -103 //ErrorModelNotFound : The specified model could not be found. This error is reported when the user specified a model that does not seem to be supported by any driver. ErrorModelNotFound = -105 //ErrorDirectoryNotFound : The specified directory could not be found. This error is reported when the user specified a directory that is non-existent. ErrorDirectoryNotFound = -107 //ErrorFileNotFound : The specified file could not be found. This error is reported when the user wants to access a file that is non-existent. ErrorFileNotFound = -108 //ErrorDirectoryExists : The specified directory already exists. This error is reported for example when the user wants to create a directory that already exists. ErrorDirectoryExists = -109 //ErrorCameraBusy : Camera I/O or a command is in progress. ErrorCameraBusy = -110 //ErrorPathNotAbsolute : The specified path is not absolute. This error is reported when the user specifies paths that are not absolute, i.e. paths like "path/to/directory". As a rule of thumb, in gphoto2, there is nothing like relative paths. ErrorPathNotAbsolute = -111 //ErrorCancel : A cancellation requestion by the frontend via progress callback and GP_CONTEXT_FEEDBACK_CANCEL was successful and the transfer has been aborted. ErrorCancel = -112 //ErrorCameraError : The camera reported some kind of error. This can be either a photographic error, such as failure to autofocus, underexposure, or violating storage permission, anything else that stops the camera from performing the operation. ErrorCameraError = -113 //ErrorosFailure : There was some sort of OS error in communicating with the camera, // e.g. lack of permission for an operation. ErrorosFailure = -114 //ErrorNoSpace : There was not enough free space when uploading a file. ErrorNoSpace = -115 ErrorReadOnly = -201 ErrorWidgetHasNoOptions = -202 ErrorWidgetIllegalOption = -203 ErrorWidgetNotImplemented = -204 )
libgphoto2 error codes. See http://www.gphoto.org/doc/api/gphoto2-result_8h.html for errors < -100 and http://www.gphoto.org/doc/api/gphoto2-port-result_8h.html for errors <= 0 >= -100
const ( //LogError : Log message is an error infomation LogError = iota //LogVerbose : Log message is an verbose debug infomation LogVerbose //LogDebug : Log message is an debug infomation LogDebug //LogData : Log message is a data hex dump LogData )
Log level
const ( //FileTypePreview is a preview of an image FileTypePreview = iota //FileTypeNormal is regular normal data of a file FileTypeNormal //FileTypeRaw usually the same as FileTypeNormal for modern cameras ( left for compatibility purposes) FileTypeRaw //FileTypeAudio is a audio view of a file. Perhaps an embedded comment or similar FileTypeAudio //FileTypeExif is the embedded EXIF data of an image FileTypeExif //FileTypeMetadata is the metadata of a file, like Metadata of files on MTP devices FileTypeMetadata )
File types
const ( SettingProgram = "expprogram" SettingFocusMode = "drivemode" SettingAperture = "aperture" SettingFocalLength = "focallength" Settingshutterspeed = "shutterspeed" SettingISO = "iso" SettingWB = "whitebalance" SettingQuality = "imagequality" SettingSize = "size" SettingLiveViewZoomRatio = "d1a3" )
Variables ¶
var CommonSettings = map[string]settingMapping{ SettingProgram: {/* contains filtered or unexported fields */}, SettingFocusMode: {/* contains filtered or unexported fields */}, SettingAperture: {/* contains filtered or unexported fields */}, SettingFocalLength: {/* contains filtered or unexported fields */}, Settingshutterspeed: {/* contains filtered or unexported fields */}, SettingISO: {/* contains filtered or unexported fields */}, SettingWB: {/* contains filtered or unexported fields */}, SettingQuality: {/* contains filtered or unexported fields */}, SettingSize: {/* contains filtered or unexported fields */}, }
CommonSettings contains common settings, some have different names since camera makers don't believe in standards
Functions ¶
func SetIdleFunc ¶
func SetIdleFunc(ctx *Context, fun ContextIdleCallback)
func SetLoggerFunc ¶
func SetLoggerFunc(fun *LogCallback)
Types ¶
type Camera ¶
type Camera struct { Ctx *Context Settings *CameraWidget // contains filtered or unexported fields }
Camera struct represents a camera connected to the computer
func NewCamera ¶
NewCamera tries to connect to a camera with name name, if name is empty it tries with the first connected camera. It returns a new Camera struct.
func (*Camera) CaptureDownload ¶
CaptureDownload is for the lazy, capture and download in one call
func (*Camera) CaptureImage ¶
func (c *Camera) CaptureImage() (*CameraFilePath, error)
CaptureImage captures image with current setings into camera's internal storage call CameraFilePath.DownloadImage to
func (*Camera) CapturePreview ¶
CapturePreview captures image preview and saves it in provided buffer
func (*Camera) DeleteFile ¶
func (camera *Camera) DeleteFile(path *CameraFilePath) error
DeleteFile tries to delete file from the camera, and returns error if it fails
func (Camera) Exit ¶
Exit Closes a connection to the camera and therefore gives other application the possibility to access the camera, too. It is recommended that you call this function when you currently don't need the camera. The camera will get reinitialized by gp_camera_init() automatically if you try to access the camera again.
func (*Camera) GetSetting ¶
func (c *Camera) GetSetting(name string) (*CameraWidget, error)
GetSetting returns a CameraWidget if it can be found among the camera settings
func (*Camera) ListFiles ¶
func (camera *Camera) ListFiles() ([]CameraStorageInfo, error)
ListFiles returns a list of files and folders on the camera
func (*Camera) LoadWidgets ¶
func (*Camera) Reset ¶
ResetCamera resets the camera port, can be needed at times https://github.com/gphoto/gphoto2/blob/7a48ea37832bcd19e17b80afef2f7f2d426419f3/gphoto2/main.c#L1675
type CameraFilePath ¶
type CameraFilePath struct { Name string Folder string Dir bool Children []CameraFilePath // contains filtered or unexported fields }
CameraFilePath is a path to a file or dir on the camera file system
func (*CameraFilePath) DownloadImage ¶
func (file *CameraFilePath) DownloadImage(buffer io.Writer, leaveOnCamera bool) error
DownloadImage saves image pointed by path to the provided buffer. If leave on camera is set to false,the file will be deleted from the camera internal storage
type CameraStorageInfo ¶
type CameraStorageInfo struct { Description string Capacity uint64 Free uint64 FreeImages uint64 Children []CameraFilePath // contains filtered or unexported fields }
CamersStorageInfo is a struct describing one of the camera's storage spaces (SD or CF cards for example) Children is a directory tree present on the storage space
type CameraWidget ¶
type CameraWidget struct {
// contains filtered or unexported fields
}
func (CameraWidget) Children ¶
func (w CameraWidget) Children() []*CameraWidget
func (*CameraWidget) Find ¶
func (w *CameraWidget) Find(name string) *CameraWidget
func (CameraWidget) Get ¶
func (w CameraWidget) Get() (interface{}, error)
func (CameraWidget) ID ¶
func (w CameraWidget) ID() int
func (CameraWidget) Info ¶
func (w CameraWidget) Info() string
func (CameraWidget) Label ¶
func (w CameraWidget) Label() string
func (CameraWidget) Name ¶
func (w CameraWidget) Name() string
func (CameraWidget) Options ¶
func (w CameraWidget) Options() ([]string, error)
func (CameraWidget) Parent ¶
func (w CameraWidget) Parent() *CameraWidget
func (CameraWidget) ReadOnly ¶
func (w CameraWidget) ReadOnly() bool
func (CameraWidget) Set ¶
func (w CameraWidget) Set(input interface{}) error
func (CameraWidget) SetInt ¶
func (w CameraWidget) SetInt(input int) error
func (*CameraWidget) String ¶
func (w *CameraWidget) String() string
func (CameraWidget) Type ¶
func (w CameraWidget) Type() WidgetType
type ContextIdleCallback ¶
type ContextIdleCallback func(Context)
ContextIdleCallback should take Context, interface{} as its arguments
var IdleCallback ContextIdleCallback
IdleCallback is the libgphoto2 context idle function. It's being called when the library is waiting for the camera so small client side updates can be done when it's called
type ContextLogCallback ¶
type ContextLogCallback func(string)
ContextLogCallback defineds a function used to log info associated to lobgphoto2 context
var ContextErrorCallback ContextLogCallback
ContextErrorCallback is the function logging error logs from libgphoto2 context. By default it logs everything to standard outout. You can assign your own method to this var
var ContextInfoCallback ContextLogCallback
ContextInfoCallback is the function logging info logs from libgphoto2 context. By default it logs everything to standard outout. You can assign your own method to this var
type GphotoError ¶
type GphotoError struct { Code int // contains filtered or unexported fields }
func (*GphotoError) Error ¶
func (g *GphotoError) Error() string
type LogCallback ¶
LogCallback defines a generic libgphoto2 logging function
var LoggerCallback LogCallback
LoggerCallback is the libgphoto2 logging function. Currently there is no possibility to add multiple log function like it is possible in native C library implementation. Default implementation log everything to standard output with log level set to DEBUG
type WidgetType ¶
type WidgetType string
const ( //WidgetWindow is the toplevel configuration widget. It should likely contain multiple #WidgetSection entries. WidgetWindow WidgetType = "window" //WidgetSection : Section widget (think Tab) WidgetSection WidgetType = "section" //WidgetText : Text widget (string) WidgetText WidgetType = "text" //WidgetRange : Slider widget (float) WidgetRange WidgetType = "range" //WidgetToggle : Toggle widget (think check box) (int) WidgetToggle WidgetType = "toggle" //WidgetRadio : Radio button widget (string) WidgetRadio WidgetType = "radio" //WidgetMenu : Menu widget (same as RADIO) (string) WidgetMenu WidgetType = "menu" //WidgetButton : Button press widget ( CameraWidgetCallback ) WidgetButton WidgetType = "button" //WidgetDate : Date entering widget (int) WidgetDate WidgetType = "date" )
widget types