Module AxisNetcam::Camera::Video
In: lib/axis-netcam/camera.rb

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

Methods

Public Instance methods

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

[Source]

# 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

Returns the current image rotation setting.

[Source]

# 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

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.

[Source]

# 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

[Validate]