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
Returns first available camera or raises NoDevicesError
when no devices are detected.
camera = GPhoto2::Camera.first
begin
# ...
ensure
camera.close
end
model = "Nikon DSC D5100 (PTP mode)"
port = "usb:250,006"
camera = GPhoto2::Camera.open(model, port)
begin
# ...
ensure
camera.close
end
Class methods
Returns all available cameras.
cameras = GPhoto2::Camera.all # => [#<GPhoto2::Camera>, #<GPhoto2::Camera>, ...]
Pass a block to automatically close the camera.
GPhoto2::Camera.first do |camera|
# ...
end
Pass a block to automatically close the camera.
GPhoto2::Camera.open(model, port) do |camera|
# ...
end
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
Instance methods
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
Check camera abilities (see Operation).
camera.can? :capture_image # => true
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.
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