Module: AxisNetcam::Camera::Video

Included in:
AxisNetcam::Camera
Defined in:
lib/axis-netcam/camera.rb

Overview

Functionality related to the camera’s video/image capabilities.

Instance Method Summary collapse

Instance Method Details

#camera_video_uri(size = :full) ⇒ Object

Returns the URI for accessing the camera’s streaming Motion JPEG video.

size

optionally specifies the image size – one of :full, :medium, or :thumbnail, or a string specifying the WxH dimensions like “640x480”.



336
337
338
339
340
341
342
343
344
345
346
# File 'lib/axis-netcam/camera.rb', line 336

def camera_video_uri(size = :full)
  case size
  when :thumbnail
    resolution = "160x120"
  when :medium
    resolution = "480x360"
  when :full
    resolution = "640x480"
  end
  "http://#{hostname}/axis-cgi/mjpg/video.cgi?resolution=#{resolution}&text=0"
end

#get_current_image_rotationObject

Returns the current image rotation setting.



349
350
351
352
353
354
355
356
# File 'lib/axis-netcam/camera.rb', line 349

def get_current_image_rotation
  v = get_parameters("Image.I0.Appearance.Rotation")
  if v && v["Image.I0.Appearance.Rotation"]
    v["Image.I0.Appearance.Rotation"]
  else
    nil
  end
end

#snapshot_jpeg(size = :full, options = {}) ⇒ Object

Returns JPEG data with a snapshot of the current camera image.

size

optionally specifies the image size – one of :full, :medium, or :thumbnail, or a string specifying the WxH dimensions like “640x480”.

options

hash of additional options (if any) to send with the image request

To dump the JPEG data to a file, you can do something like this:

# Instantiate c as a AxisNetcam::Camera object, and then...
data = c.snapshot_jpeg
f = File.open('/tmp/test.jpg', 'wb')
f.binmode
f.write(data)
f.close

The options hash can include parameters such as ‘compression’, ‘rotation’, ‘date’, etc. See www.axis.com/techsup/cam_servers/dev/cam_http_api_2.htm#api_blocks_image_video_jpeg_snapshot for more information.



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/axis-netcam/camera.rb', line 317

def snapshot_jpeg(size = :full, options = {})
  case size
  when :thumbnail
    resolution = "160x120"
  when :medium
    resolution = "480x360"
  when :full
    resolution = "704x480"
  else
    resolution = size
  end
  
  axis_action("jpg/image.cgi", 
    options.merge('resolution' => resolution))
end