gphoto

package module
v0.0.0-...-90db6d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2015 License: MIT Imports: 6 Imported by: 0

README

gphoto

Package gphoto let you control your digital camera or webcam from your PC.

Gphoto is a go wrapper for libgphoto2 library (http://www.gphoto.org/proj/libgphoto2/).

It supports most of modern cameras supporting PTP protocol and connecting to PC with an USB cable. Gphoto lets you inspect and modify camera settings ( shutter speed, aperture, iso, image quality etc.), capture photos and download them to the PC.

You can also capture image previews and by doing it in a loop you can have live view on your computer screen

You will need to have installed libgphoto2 on your system before you wil be able to use this package. To do it on Ubuntu and other debian derivatives you need to type in the terminal :

sudo apt get install libgphoto2-6 libgphoto2-port10

You might also need to change the library path in source files to tell go compiler where to find library files. By default the compiler expects to find libgphoto in

/usr/lib/x86_64-linux-gnu

Documentation

Overview

Package gphoto let you control your digital camera or webcam from your PC.

Package gphoto is a go wrapper for libgphoto2 library (http://www.gphoto.org/proj/libgphoto2/) It is supporting most of modern cameras supporting PTP protocol and connecting to PC with an USB cable

Gphoto lets you inspect and modify camera settings ( shutter speed, aperture, iso, image quality etc.), capture photos and download them to the PC.

You can also capture image previews and by doing it in a loop you can have live view on your computer screen

For more information about installing required dependencies and troubleshooting please read readme file avaiable in the github repo under this link: https://github.com/szank/libgphoto2-go/blob/master/README.md

Index

Constants

View Source
const (

	//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
)

gphoto2 errors

View Source
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

View Source
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

Variables

This section is empty.

Functions

This section is empty.

Types

type Camera

type Camera struct {
	CameraSettings CameraWidget
	// contains filtered or unexported fields
}

Camera struct represents a camera connected to the computer

func GetNewGPhotoCamera

func GetNewGPhotoCamera(context *Context) (*Camera, error)

GetNewGPhotoCamera returns a new camera instance

func (*Camera) CaptureImage

func (camera *Camera) CaptureImage() (*CameraFilePath, error)

CaptureImage captures image with current setings into camera's internal storage

func (*Camera) CapturePreview

func (camera *Camera) CapturePreview(buffer io.Writer) error

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) GetWidgetTree

func (camera *Camera) GetWidgetTree() error

GetWidgetTree returns a widget tree for selected camera

func (*Camera) ListFiles

func (camera *Camera) ListFiles() ([]CameraStorageInfo, error)

ListFiles returns a lits of files and folders on the camera

func (*Camera) PrintWidgetTree

func (camera *Camera) PrintWidgetTree(file io.Writer)

PrintWidgetTree prints widget hierarchy to the output buffer

type CameraFilePath

type CameraFilePath struct {
	Name     string
	Folder   string
	Isdir    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 interface {
	Label() string
	Name() string
	Info() string
	Type() WidgetType
	Children() []CameraWidget
	ReadOnly() bool
}

CameraWidget is a representation of one of the cameras's setting or control knob

type CameraWidgetMenu

type CameraWidgetMenu interface {
	CameraWidgetText
	GetChoices() ([]string, error)
}

type CameraWidgetRadio

type CameraWidgetRadio CameraWidgetMenu

type CameraWidgetText

type CameraWidgetText interface {
	Get() (*string, error)
	Set(*string) error
}

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context represents a context in which all other calls are executed

func GetNewGPhotoContext

func GetNewGPhotoContext() (*Context, error)

GetNewGPhotoContext returns a new gphoto context

func (Context) Free

func (c Context) Free()

Free should be called afer you don't need the context anymore

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 LogCallback

type LogCallback func(int, string, string)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL