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”.



226
227
228
229
230
231
232
233
234
235
236
# File 'lib/axis-netcam/camera.rb', line 226

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

#snapshot_jpeg(size = :full) ⇒ 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”.

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


207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/axis-netcam/camera.rb', line 207

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