class GPhoto2::Camera
 
  - GPhoto2::Camera
 - Reference
 - Object
 
Included Modules
- GPhoto2::Camera::Capture
 - GPhoto2::Camera::Configuration
 - GPhoto2::Camera::Event
 - GPhoto2::Camera::Filesystem
 - GPhoto2::Camera::ID
 - GPhoto2::Camera::Info
 - GPhoto2::Struct(LibGPhoto2::Camera)
 
Defined in:
gphoto2/camera.crgphoto2/camera/capture.cr
gphoto2/camera/configuration.cr
gphoto2/camera/event.cr
gphoto2/camera/filesystem.cr
gphoto2/camera/id.cr
gphoto2/camera/info.cr
Constructors
- 
        .first : self
        
          
Returns first available camera or raises
NoDevicesErrorwhen no devices are detected. - .new(model : String, port : String)
 - 
        .open(model : String, port : String) : self
        
          
 
Class Method Summary
- 
        .all : Array(self)
        
          
Returns all available cameras.
 - 
        .first(&) : Nil
        
          
Pass a block to automatically close the camera.
 - 
        .first? : self | Nil
        
          
Returns first available camera, or
nilwhen no devices are detected. - 
        .open(model : String, port : String, &) : Nil
        
          
Pass a block to automatically close the camera.
 - 
        .where(*, model : String | Regex | Nil = nil, port : String | Regex | Nil = nil) : Array(self)
        
          
Filters devices by a given condition.
 
Instance Method Summary
- 
        #==(other : self)
        
          
Returns
trueif this reference is the same as other. - #abilities : CameraAbilities
 - 
        #autorelease(&) : Nil
        
          
Ensures the camera is finalized when passed a block.
 - 
        #can?(operation : Operation)
        
          
Check camera abilities (see
Operation). - #close : Nil
 - #context : Context
 - 
        #exit : Nil
        
          
Closes a connection to the camera and therefore gives other application the possibility to access the camera, too.
 - #model : String
 - #port : String
 - #port_info : PortInfo
 - #ptr
 - #with_port(&) : Nil
 
Instance methods inherited from module GPhoto2::Camera::ID
  
  
    
      id : UUID
    id, 
    
  
    
      serialnumber : String | Nil
    serialnumber
    
  
    
    
    
  
    
  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
    /, 
    
  
    
      blob(path : Path | String) : CameraFile
    blob, 
    
  
    
      filesystem(path : 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 : Enumerable(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
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 Method Detail
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 Method Detail
Returns true if this reference is the same as other. Invokes same?.
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.