Class: Viewer

Viewer(options)

A Viewer can be used to stream a single MJPEG topic into a canvas. Emits the following events: * 'warning' - emitted if the given topic is unavailable * 'change' - emitted with the topic name that the canvas was changed to

Constructor

new Viewer(options)

Parameters:
Name Type Description
options Object possible keys include:
Properties
Name Type Attributes Description
divID string the ID of the HTML div to place the canvas in
canvas HTMLCanvasElement <optional>
(optional) the canvas to render the images to. Will override divID
width number the width of the canvas
height number the height of the canvas
host string the hostname of the MJPEG server
port number <optional>
(optional) - the port to connect to
quality number <optional>
(optional) - the quality of the stream (from 1-100)
topic string the topic to stream, like '/wide_stereo/left/image_color'
overlay HTMLCanvasElement <optional>
(optional) - a canvas to overlay after the image is drawn
refreshRate number <optional>
(optional) - a refresh rate in Hz, will be converted into milliseconds and take max value between refreshRate and interval
interval number <optional>
(optional) - an interval time in milliseconds, will take max value between refreshRate and interval
invert boolean <optional>
(optional) - if the images are mirrored
type string <optional>
(optional) - the encoding method for the stream, default set to mjpeg
src string <optional>
(optional) - the source URL for the images, passing values will override other params (host, port, quality, etc)
Source:

Methods

changeStream(topic)

Change the stream's topic
Parameters:
Name Type Description
topic string the topic to change the stream to
Source:

draw()

A function to draw the image onto the canvas.
Source:

unmount()

Remove interval and image src to close HTTP connection.
Source: