Class AxisNetcam::Camera
In: lib/axis-netcam/camera.rb
Parent: Object

The AxisNetcam::Camera class represents an Axis network camera.

To control a camera, first create an instance of a Camera object and then call its methods. For example:

  require 'axis-netcam/camera'

  c = AxisNetcam::Camera.new(:hostname => '192.168.2.25',
        :username => 'root', :password => 'pass')

  puts c.get_position[:tilt]
  c.tilt(90)
  puts c.camera_video_uri

For a list of available methods, see the RDocs for included modules:

AxisNetcam::Camera::PTZ :for point-tilt-zoom control
AxisNetcam::Camera::Users :for user management
AxisNetcam::Camera::Video :for obtaining video/image data
AxisNetcam::Camera::Info :for diagnostic/status information

Note that by default, AxisNetcam::Camera will log quite verbosely to stdout. See AxisNetcam::Camera#new for info on how to change this behaviour.

Methods

disconnect   new   to_s  

Included Modules

PTZ Users Video Info

Classes and Modules

Module AxisNetcam::Camera::Info
Module AxisNetcam::Camera::PTZ
Module AxisNetcam::Camera::Users
Module AxisNetcam::Camera::Video
Class AxisNetcam::Camera::InvalidLogin
Class AxisNetcam::Camera::RemoteError
Class AxisNetcam::Camera::RemoteTimeout

Attributes

hostname  [R] 
logger  [R] 

Public Class methods

Create a new Camera object. Options must include a :hostname, :username, and :password. A Logger object can also be specified to the :logger option, otherwise logging will be done to STDOUT.

[Source]

# File lib/axis-netcam/camera.rb, line 58
    def initialize(options)
      @hostname = options[:hostname] or raise(ArgumentError, "Must specify a hostname")
      @username = options[:username] or raise(ArgumentError, "Must specify a username")
      @password = options[:password] or raise(ArgumentError, "Must specify a password")
      @log = options[:logger] || Logger.new(STDOUT)
    end

Public Instance methods

[Source]

# File lib/axis-netcam/camera.rb, line 512
    def disconnect
      if @http && @http.active?
        @log.debug "AXIS REMOTE API closing HTTP connection #{@http}"
        @http.close
        @http = nil
      else
        @log.warn "AXIS REMOTE API cannot disconnect because the HTTP connection is not open"
      end
    end

[Source]

# File lib/axis-netcam/camera.rb, line 508
    def to_s
      "#<#{self.class}:#{self.hostname}:#{self.object_id}>"
    end

[Validate]