<ahref="https://github.com/jeromeetienne/AR.js/"target="_blank">AR.js</a> - tango example for a-frame by <ahref='https://twitter.com/jerome_etienne'target='_blank'>@jerome_etienne</a>
The ARController is the main object for doing AR marker detection with JSARToolKit.
To use an ARController, you need to tell it the dimensions to use for the AR processing canvas and
pass it an ARCameraParam to define the camera parameters to use when processing images.
The ARCameraParam defines the lens distortion and aspect ratio of the camera used.
See https://www.artoolworks.com/support/library/Calibrating_your_camera for more information about AR camera parameteters and how to make and use them.
If you pass an image as the first argument, the ARController uses that as the image to process,
using the dimensions of the image as AR processing canvas width and height. If the first argument
to ARController is an image, the second argument is used as the camera param.
The camera parameters argument can be either an ARCameraParam or an URL to a camera definition file.
If the camera argument is an URL, it is loaded into a new ARCameraParam, and the ARController dispatches
a 'load' event and calls the onload method if it is defined.
@exports ARController
@constructor
@param {number} width The width of the images to process.
@param {number} height The height of the images to process.
@param {ARCameraParam | string} camera The ARCameraParam to use for image processing. If this is a string, the ARController treats it as an URL and tries to load it as a ARCameraParam definition file, calling ARController#onload on success.
Get the number of markers detected in a video frame.
@return {number} The number of detected markers in the most recent image passed to arDetectMarker.
Note that this is actually a count, not an index. A better name for this function would be
arGetDetectedMarkerCount, but the current name lives on for historical reasons.
*/
ARController.prototype.getMarkerNum=function(){
returnartoolkit.getMarkerNum(this.id);
};
/**
Get the marker info struct for the given marker index in detected markers.
Call this.detectMarker first, then use this.getMarkerNum to get the detected marker count.
The returned object is the global artoolkit.markerInfo object and will be overwritten
by subsequent calls. If you need to hang on to it, create a copy using this.cloneMarkerInfo();
Returns undefined if no marker was found.
A markerIndex of -1 is used to access the global custom marker.
The fields of the markerInfo struct are:
@field area Area in pixels of the largest connected region, comprising the marker border and regions connected to it. Note that this is
not the same as the actual onscreen area inside the marker border.
@field id If pattern detection mode is either pattern mode OR matrix but not both, will be marker ID (>= 0) if marker is valid, or -1 if invalid.
@field idPatt If pattern detection mode includes a pattern mode, will be marker ID (>= 0) if marker is valid, or -1 if invalid.
@field idMatrix If pattern detection mode includes a matrix mode, will be marker ID (>= 0) if marker is valid, or -1 if invalid.
@field dir If pattern detection mode is either pattern mode OR matrix but not both, and id != -1, will be marker direction (range 0 to 3, inclusive).
@field dirPatt If pattern detection mode includes a pattern mode, and id != -1, will be marker direction (range 0 to 3, inclusive).
@field dirMatrix If pattern detection mode includes a matrix mode, and id != -1, will be marker direction (range 0 to 3, inclusive).
@field cf If pattern detection mode is either pattern mode OR matrix but not both, will be marker matching confidence (range 0.0 to 1.0 inclusive) if marker is valid, or -1.0 if marker is invalid.
@field cfPatt If pattern detection mode includes a pattern mode, will be marker matching confidence (range 0.0 to 1.0 inclusive) if marker is valid, or -1.0 if marker is invalid.
@field cfMatrix If pattern detection mode includes a matrix mode, will be marker matching confidence (range 0.0 to 1.0 inclusive) if marker is valid, or -1.0 if marker is invalid.
@field pos 2D position (in camera image coordinates, origin at top-left) of the centre of the marker.
@field line Line equations for the 4 sides of the marker.
@field vertex 2D positions (in camera image coordinates, origin at top-left) of the corners of the marker. vertex[(4 - dir)%4][] is the top-left corner of the marker. Other vertices proceed clockwise from this. These are idealised coordinates (i.e. the onscreen position aligns correctly with the undistorted camera image.)
@param {number} markerIndex The index of the marker to query.