VideoOverlay Plugin

Access the VideoOverlay JavaScript api through the global ezar.  You must initialize the plugin before accessing its cameras. During initialization native mobile services are configured to render a live video stream from  a mobile device camera onto a custom camera view that is created and positioned below the Cordova WebView control. By default the Cordova WebView control has the same dimensions as the camera view. In some cases the camera view and WebView size maybe smaller than the device display due to automatic scaling performed by VideoOverlay to maintain a consistent aspect ratio of the video stream. This behavior can be overridden in the initializeVideoOverlay() method.  Use the options background property to provide an #RRGGBB color that will be rendered as the cameraView's background color when a camera is not running.

When a camera is started it is known as the active camera and it's video is rendered on the camera view.  At this time the video content is NOT saved to the device's photo gallery. 


Installation

The VideoOverlay plugin does not require additional ezAR plugins. Install the plugin using any Cordova plugin installation tool. 

   example - from Cordova commandline enter
     cordova plugin add plugins/com.ezartech.ezar.videooverlay

Use-cases and Snippets

See the Docs page for primary use-cases and snippets.


videoOverlay module JavaScript API

  ezar.initializeVideoOverlay(successCB, errorCB, options)

Asynchronously set up the native mobile services; initialize the ezAR cameras and the Cordova WebView to enable rendering a live video stream from one of the mobile device cameras. Upon completion you can access all other VideoOverlay methods including the device cameras. A success or failure result is indicated by invoking the corresponding successCB or errorCB function parameter.

parameters

  • successCB  Function (optional)
  • errorCB Function (optional)
  • options (optional)
    • backgroundColor - #RRGGBB String, default=#FFFFFF,  background color is visible when no camera is running and the <body> element's background is transparent.
    • fitWebViewToCameraView - boolean, default=true, when needed resize WebView to that of the CameraView.
ezar.isVideoOverlayInitialized()

Check if  ezAR VideoOverlay plugin has been initialized.

returns

  • true when sdk has been initialized; false otherwise  
ezar.hasBackCamera()

Check if ezAR detected  a camera on the back of the device.

returns

  • true when a back facing camera has been detected; false otherwise
ezar.getBackCamera()

Return the camera on the back of the device.

returns

  • camera  Object, The back facing camera or null if no camera was detected.
ezar.hasFrontCamera()

Check if ezAR detected  a camera on the front of the device.

returns

  • true when a front facing camera has been detected; false otherwise
ezar.getFrontCamera()

Return the camera on the front of the device.

returns

  • camera  Object,  The front facing camera  or null if no camera was detected.
ezar.getCameras()

Return all of the device cameras

returns 

  • camera  Array,  The array  contains all of the cameras detected. An empty array is returned if no cameras were detected or an error occurred during initialization. 
ezar.getActiveCamera()

Return the camera that is currently running.

returns

  • camera Object, the camera currently running or null if no camera is running
ezar.hasActiveCamera()

Check if there is a camera currently running.

returns

  • true if there is camera that is running; false otherwise
ezar.getDisplaySize()

The size of the device display.

returns

  • Object {width: <int>, height: <int>}

Camera API

Control mobile device camera features. Access the desired camera using ezar.getBackCamera(), ezar.getFrontCamera() or ezar.getActiveCamera(). Then use the following API to inspect and control the camera.

getPosition()

Answer the FRONT or BACK device relative position of the camera.

return

  • String "FRONT" or "BACK"
isRunning()

Answer if camera is running.

returns

  • boolean, true when camera is running; false otherwise
start(successCB, errorCB)

Asynchronously starts the camera  video stream to begin rendering on  the camera view. The video layer has the same dimensions as the WebView control. The video content is NOT saved to the device's photo gallery.

parameters

  • successCB Function (optional)
  • errorCB Function (optional)
stop(successCB, errorCB)

Asynchronously stops the camera video rendering. The camera view background color is set to black.

parameters

  • successCB Function (optional)
  • errorCB Function (optional)
hasZoom()

Inspect if the camera supports zooming (scaling).

returns

  • bool, true if the camera can be zoomed; false otherwise
getZoom

Returns the current zoom level (scale factor).

returns

  • Float,  zoom level between 1.0 and maxZoom, returns 0.0 if zoom is not supported
setZoom(newZoomLevel, successCB, errorCB)

Asynchronously update the camera zoom level.

parameters

  • newZoomLevel Float,  must be between 1.0 and maxZoom
  • successCB Function (optional),
  • errorCB Function (optional),
getMaxZoom()

Return the maximum zoom level supported by this camera.

returns

  • Float,  the maximum zoom level supported by the camera or 0.0 if zoom is not supported
updated 20170310

Plugins
  Video Overlay
  Face Detection
  Snapshot
  Flashlight

ic_camera_alt_grey600_48dp.png
 
getHorizontalViewAngle()

Return the horizontal angle of view when the device is in landscape orientation.

returns

  • Float, the angle in degress
getVerticalViewAngle()

Return the vertical angle of view when the device is in landscape orientation.

returns

  • Float, the angle in degress

Android - vertical view angle is provided by the native camera api
iOS - vertical view angle is computed based on the native horizontal view angle api using this formula