A Javascript library for Augmenta Tracking using Websocket, created by Théoriz Studio.
Try the live examples here
To run the examples you can click here or run them locally on a web server for local development such as Servez and open the repo's folder.
There is two examples : a very simple one using no other librairies than this one, and a more complex example adapted from a three js example.
- Augmenta-js/Simple Example/simpleExample.html
- Augmenta-js/three js example/examples/webgl_gpgpu_bird.html
Important note :
If you run AugmentaFusion and the examples on a local server (such as Servez) on the same computer you will be able to use both secure connection and regular connection. However - as AugmentaFusion is not able to send secure connection to browsers - if you want to run the examples on a different computer you will have to set your local server in http instead of https. You will also have to make sure secure connections are disabled on both client (these examples or your own example) and server (AugmentaFusion) sides. If you want to try the examples on the github page you will just have to disbale secure connections in the example interface and in AugmentaFusion (the github page is set in http by default for that matter).
var augmentaManager = new AugmentaManager()
augmentaManager.startAugmentaWebsocket()Default websocket url : ws://127.0.0.1:8080.
Once the connection is opened, the augmenta manager receives and parses all the messaged from the websocket address.
You can change the websocket's address either by changing the port and/or the ip or by changing the entire url directly. The websocket connection will be automatically closed and reopened if the address is valid. Make sure the address is the same as your websocket output running in fusion.
augmentaManager.changePort(port)augmentaManager.changeIP(ip)augmentaManager.websocketurl = websocketurlWith port a number or a string, ip a string and websocketurl a string
augmentaManager.useSecureConnection = trueAllows you to enable or disable secure conection (by default disablbed)
You can change the default functions called whenever the augmenta manager receives a message or closes/opens a websocket connection.
augmentaManager.setObjectEntered(objectEntered)augmentaManager.setObjectUpdated(objectEntered)augmentaManager.setObjectWillLeave(objectEntered)With objectEntered, objectUpdated and objectWillLeave javascript functions taking an instance of class AugmentaObject as only argument.
augmentaManager.setWebsocketOpened(websocketOpened)augmentaManager.setWebsocketClosed(websocketClosed)With websocketOpened and websocketClosed javascript functions taking no argument.
augmentaManager.setFusionUpdated(objectEntered)With fusionUpdated a javascript function taking an instance of class Fusion as only argument.
You can change the time an inactive object is stored by the augmenta manager.
augmentaManager.timeOut = timeOutWith timeOut the number of frame an object can remain inactive before being removed from the scene.
For instances of class AugmentaManager you can access :
augmentaObjects
A dictionary containing all augmenta objects in the current frame of typeAugmentaObjectindexed by theiroid.newestObject
The youngest augmenta object of typeAugmentaObjectin the current frameoldestObject
The oldest augmenta object of typeAugmentaObjectin the current frameaugmentaScene
The current augmenta scene of classAugmentaScene.fusion
An instance of classFusionstoring fusion's informations.
For instances of class AugmentaObject you can access:
-
frame -
id -
oid -
age -
centroid(of classvec2) -
velocity(of classvec2) -
orientation -
boundingRect(of classBoundingRect) -
height -
lastSeenthe scene's frame it was last seen in -
color(for display purposes only)
If extra data are also sent you can also access:
highestthe position of the highest point (of classvec2)distancereflectivity
For instances of class AugmentaScene you can access:
frameobjectCountscene(of classvec2)
For instances of class Fusion you can access:
offsetthe offset in scene in meters (of classvec2)videoOutthe size of the video output in meters (of classvec2)videoOutInPixelsthe size of the video output in pixels (of classvec2)
Other informations you might need :
augmentaManager.getPixelPerMeter()To know the pixel density in width and height.
augmentaManager.getObjectRelativePosition(oid)To get an object's relative position in the scene. Returns a vec2.
