Developer Info

adsfasdf

Before You Start

1. Stay up to date

Before going deep with ezAR, check out the latest progress report to learn what's new and about any known issues. Even better sign up for the ezAR Newsletter at the bottom of the page.

2. New to Cordova Hybrid-Mobile SDK 

ezAR is provided as a plugin for the Apache Cordova SDK and Cordova-compatible  SDKs such as PhoneGap,  Ionic, Sencha and others. If you are new to software development using the Cordova SDK see the resources section at the bottom of this page.


Download and Installing ezAR SDK

1. Download

Download the ezAR Startup Kit (zip) from here

2. Install ezAR Startup Kit Software

  1. Unzip the the ezAR using your favorite Zip file utility,  e.g., WinZip or 7-Zip to your local file system. 
  2. Installing the ezAR Startup Kit plugin into your Cordova-compatible project.
cordova plugin add <path-to-ezar-software>/plugin

ezAR Use-Cases & Snippets

This snippet initializes ezAR, starts the camera on the back of the device and lastly sets the HTML <body> background color to transparent. 

ezar.initialize(
  function() {
    ezar.getBackCamera().start();
    document.body.style.backgroundColor = 'transparent';
  },
  function(error) {
    alert("ezar initialization failed");
  });

Step-1: Initialize ezAR (line 1)

Before you can use the full ezAR JavaScript API you must first initialize it using the global, ezar's  initialize function. This step sets up the native mobile services to enable rendering a live video stream using a mobile device camera. Upon completion you can access all other ezar functions including the cameras. The initialize() function executes asynchronously.

ezar.initialize(successCB,errorCB)
successCB - function called on successful initialization 
errorCB - function called on initialization failure

Step-2: Select a Camera (line 3)

Next select the camera by its position on the device for the application to use. Most devices are equipped with at least 1 camera on the back of the device.  An additional camera mounted on the front of the device is also common especially on the newer high end mobile devices.

var backCamera = ezar.getBackCamera();
var frontCamera = ezar.getFrontCamera();

Step-3: Start the Camera (line 3)

When the ezAR camera is started, a video stream will begin rendering on a UI layer below the Cordova WebView control. The video layer has the same dimensions as the WebView control. The video content is NOT saved to the device's photo gallery. The start() function executes asynchronously.

camera.start(successCB,errorCB)
successCB - function called on successful
errorCB - function called on failure

NOTE: In addition to starting the camera you must also configure the web UI to be transparent otherwise the video will not be visible. You can set the entire display or a region of the web UI transparent. The example below programmatically sets the HTML document <body> to be transparent. 

Step-4: Adjust Camera Zoom Level (scale)

Most device cameras support zooming the camera. The camera api includes the following functions:

camera.hasZoom()
- returns true if camera supports zoom level adjustment

camera.getZoom() 
- returns scaling factor as a float on range [1.0, maxZoom]

camera.setZoom(aFloat)
- set scaling factor, aFloat on range [1.0, maxZoom]

camera.getMaxZoom()
- returns maximum level of the zoom range

Step-5: Activate/Deactivate the Device Light

If the device is equipped with a light on the same side of the device then use the camera functions to interact with it. 

camera.hasLight() 
- returns true if device has a light on same side as the camera

camera.getLight() 
- returns int, 0 = light off, 1 = light on

camera.setLight(0_or_1)
- 0 = turn light off, 1 = turn light on

Step-6: Stop the Camera

Finally use the stop() function  to suspend the video stream and rendering. This operation executes asynchronous. 

camera.stop(successCB,errorCB)
successCB - function called on successful
errorCB - function called on failure

Step-7: Resume the Camera

When a camera is stopped it can be resumed using the start() function. Alternatively if the device is equipped with front and back cameras you can switch between them. You do not have to stop the current camera before starting another camera. ezAR automatically handles  the internal state of the cameras. 


ezAR JavaScript API

ezar.js module

Access the JavaScript api through the global ezar

initialize(successCB,errorCB)

isInitialized()
hasBackCamera()
getBackCamera()
hasFrontCamera()
getFrontCamera()

getCameras()

getActiveCamera()

hasActiveCamera()

getDisplaySize()

camera.js module

Control mobile device camera features. ezAR 

getPosition()
start(successCB,errorCB)

stop(successCB,errorCB)

isRunning()

hasZoom()

getZoom()

setZoom(successCB,errorCB)

getMaxZoom()

hasLight()

getLight()

setLight(successCB,errorCB)




ezar.initialize(successCB,errorCB)
parameters
successCB - function called on successful initialization errorCB - function called on initialization failure
s

s

embed Block
Add an embed URL or code. Learn more.