class

GPhoto2::Camera

Inherits GPhoto2::Camera::ID / GPhoto2::Camera::Info / GPhoto2::Camera::Filesystem / GPhoto2::Camera::Event / GPhoto2::Camera::Configuration / GPhoto2::Camera::Capture / GPhoto2::Struct / Reference / Object

Constructors

first

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

camera = GPhoto2::Camera.first

begin
  # ...
ensure
  camera.close
end
Source
new(model : String, port : String)
Source
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
Source

Class methods

all

Returns all available cameras.

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

Pass a block to automatically close the camera.

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

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

Source
open(model : String, port : String, &) : Nil

Pass a block to automatically close the camera.

GPhoto2::Camera.open(model, port) do |camera|
  # ...
end
Source
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
Source

Instance methods

==(other : self)

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

Source
abilities
Source
autorelease

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
Source
can?(operation : Operation)

Check camera abilities (see Operation).

camera.can? :capture_image # => true
Source
close
Source
context
Source
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.

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

Source
model
Source
port
Source
port_info
Source
with_port

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
Source

Nested types