Class: AxisNetcam::Camera

Inherits:
Object
  • Object
show all
Includes:
Info, PTZ, Users, Video
Defined in:
lib/axis-netcam/camera.rb

Overview

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.

Defined Under Namespace

Modules: Info, PTZ, Users, Video Classes: InvalidLogin, RemoteError, RemoteTimeout

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Info

#get_parameters, #model, #server_report, #status_code, #status_message

Methods included from Video

#camera_video_uri, #get_current_image_rotation, #snapshot_jpeg

Methods included from Users

#add_or_update_user, #add_user, #remove_user, #update_user, #user_exists?, #users

Methods included from PTZ

#calibrate, #center_on, #get_position, #get_preset_positions, #get_ptz_limits, #move, #pan, #point_at_preset_name, #ptz, #tilt, #zoom

Constructor Details

#initialize(options) ⇒ Camera

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.



58
59
60
61
62
63
# 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

Instance Attribute Details

#hostnameObject (readonly)

Returns the value of attribute hostname.



52
53
54
# File 'lib/axis-netcam/camera.rb', line 52

def hostname
  @hostname
end

#loggerObject (readonly)

Returns the value of attribute logger.



52
53
54
# File 'lib/axis-netcam/camera.rb', line 52

def logger
  @logger
end

Instance Method Details

#disconnectObject



512
513
514
515
516
517
518
519
520
# 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

#to_sObject



508
509
510
# File 'lib/axis-netcam/camera.rb', line 508

def to_s
  "#<#{self.class}:#{self.hostname}:#{self.object_id}>"
end