Home Reference Source
import Camera from 'sayhello/js/camera.js'
public class | source

Camera

provides easy functions to take images, sets up a video and canvas element

Constructor Summary

Public Constructor
public

constructor(mediaOptions: Object, width: number)

creates an instance of Camera

Member Summary

Public Members
public

canvas: *

type {Object}

public

video: *

type {Object}

public

width: *

type {number}

Method Summary

Public Methods
public

sets the resolution of both video and canvas element, so that no distortion happens.

public

takes an image by drawing the video element's content on the canvas.

Public Constructors

public constructor(mediaOptions: Object, width: number) source

creates an instance of Camera

Params:

NameTypeAttributeDescription
mediaOptions Object
  • optional
  • default: { video: true, audio: false }

configuration for getUserMedia

width number
  • optional
  • default: 640

width in pixels for the video element

Public Members

public canvas: * source

type {Object}

public video: * source

type {Object}

public width: * source

type {number}

Public Methods

public setResolution(): Object source

sets the resolution of both video and canvas element, so that no distortion happens.

Return:

Object

Object with attributes width and height, calculated.

public takeImage(): Object source

takes an image by drawing the video element's content on the canvas.

Return:

Object

the canvas element (can be used to access functions such as .toBlob())