class GPhoto2::Camera

Included Modules

Defined in:

gphoto2/camera.cr
gphoto2/camera/capture.cr
gphoto2/camera/configuration.cr
gphoto2/camera/event.cr
gphoto2/camera/filesystem.cr
gphoto2/camera/id.cr
gphoto2/camera/info.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module GPhoto2::Camera::ID

id : UUID id

Instance methods inherited from module GPhoto2::Camera::Info

about_text : String about_text, manual_text : String manual_text, summary_text : String summary_text

Instance methods inherited from module GPhoto2::Camera::Filesystem

/(path) : CameraFolder /, filesystem(path : String = "/") : CameraFolder filesystem, filesystem_reset : Nil filesystem_reset

Instance methods inherited from module GPhoto2::Camera::Event

wait(timeout : Time::Span = 2.seconds) : CameraEvent wait, wait_for(event_type : CameraEvent::Type, timeout : Time::Span = 2.seconds) : CameraEvent wait_for

Instance methods inherited from module GPhoto2::Camera::Configuration

<<(widget : CameraWidget::Base) : self <<, [](key : String | Symbol) : CameraWidget::Base [], []=(key : String | Symbol, value) []=, []?(key : String | Symbol) : CameraWidget::Base | Nil []?, config : Hash(String, CameraWidget::Base) config, dirty? dirty?, preserving_config(keys : Array(String | Symbol) | Nil = nil, &) : Nil preserving_config, reload : Nil reload, save : Bool save, update(attributes) : Bool update, window : CameraWidget::Window window

Instance methods inherited from module GPhoto2::Camera::Capture

capture : CameraFile capture, preview : CameraFile preview, trigger : Nil trigger

Instance methods inherited from module GPhoto2::Struct(LibGPhoto2::Camera)

ptr : Pointer(T) ptr, ptr? : Pointer(T) | Nil ptr?, to_unsafe : Pointer(T) to_unsafe, wrapped : T wrapped

Constructor methods inherited from module GPhoto2::Struct(LibGPhoto2::Camera)

new(ptr : Pointer(T) | Nil = nil) new

Constructor Detail

def self.first : self #

Returns first available camera or raises NoDevicesError when no devices are detected.

camera = GPhoto2::Camera.first

begin
  # ...
ensure
  camera.close
end

[View source]
def self.new(model : String, port : String) #

[View source]
def self.open(model : String, port : String) : self #
model = "Nikon DSC D5100 (PTP mode)"
port = "usb:250,006"

camera = GPhoto2::Camera.open(model, port)

begin
  # ...
ensure
  camera.close
end

[View source]

Class Method Detail

def self.all : Array(self) #

Returns all available cameras.

cameras = GPhoto2::Camera.all # => [#<GPhoto2::Camera>, #<GPhoto2::Camera>, ...]

[View source]
def self.first(&) : Nil #

Pass a block to automatically close the camera.

GPhoto2::Camera.first do |camera|
  # ...
end

[View source]
def self.first? : self | Nil #

Returns first available camera, or nil when no devices are detected.


[View source]
def self.open(model : String, port : String, &) : Nil #

Pass a block to automatically close the camera.

GPhoto2::Camera.open(model, port) do |camera|
  # ...
end

[View source]
def self.where(*, model : String | Regex | Nil = nil, port : String | Regex | Nil = nil) : Array(self) #

Filters devices by a given condition.

Filter keys can be either model or port. Only the first filter is used.

# Find the cameras whose model names contain Nikon.
cameras = GPhoto2::Camera.where(model: /nikon/i)

# Select a camera by its port.
camera = GPhoto2::Camera.where(port: "usb:250,004").first

[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


[View source]
def abilities : CameraAbilities #

[View source]
def autorelease(&) : Nil #

Ensures the camera is finalized when passed a block.

# Find the cameras whose model names contain Nikon.
cameras = GPhoto2::Camera.where(model: /nikon/i)

# Pass a block, which will automatically close the camera.
cameras.first.autorelease do |camera|
  # ...
end

[View source]
def can?(operation : Operation) #

Check camera abilities (see Operation).

camera.can? :capture_image # => true

[View source]
def close : Nil #

[View source]
def context : Context #

[View source]
def exit : Nil #

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.

NOTE The camera will get reinitialized if you try to access the camera again.


[View source]
def model : String #

[View source]
def port : String #

[View source]
def port_info : PortInfo #

[View source]
def ptr #

[View source]
def with_port(&) : Nil #

Yields opened instance of Port with already associated camera's PortInfo. Port is automatically closed on block exit/exception.

To reset given camera's port you can do:

camera.with_port do |port|
  camera.exit
  port.reset
end

[View source]