Apriltag WASM Detector
Apriltag detector using the apriltag C library and compiled to WASM using emscripten.
Macros | Functions
apriltag_js.c File Reference

Apriltag detection to be compile with emscripten. More...

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <ctype.h>
#include <unistd.h>
#include <math.h>
#include "apriltag.h"
#include "apriltag_pose.h"
#include "tag36h11.h"
#include "tag25h9.h"
#include "tag16h5.h"
#include "tagCircle21h7.h"
#include "tagStandard41h12.h"
#include "common/getopt.h"
#include "common/image_u8.h"
#include "common/image_u8x4.h"
#include "common/pjpeg.h"
#include "common/zarray.h"
#include "apriltag_js.h"
#include "str_json.h"
Include dependency graph for apriltag_js.c:

Functions

EMSCRIPTEN_KEEPALIVE int atagjs_init ()
 Init the apriltag detector with given family and default options default options: quad_decimate=2.0; quad_sigma=0.0; nthreads=1; refine_edges=1; return_pose=1. More...
 
EMSCRIPTEN_KEEPALIVE int atagjs_destroy ()
 Releases resources. More...
 
EMSCRIPTEN_KEEPALIVE int atagjs_set_detector_options (float decimate, float sigma, int nthreads, int refine_edges, int max_detections, int return_pose, int return_solutions)
 Sets the given detector options. More...
 
EMSCRIPTEN_KEEPALIVE int atagjs_set_pose_info (double fx, double fy, double cx, double cy)
 Sets camera intrinsics (in pixels) for tag pose estimation. More...
 
EMSCRIPTEN_KEEPALIVE uint8_t * atagjs_set_img_buffer (int width, int height, int stride)
 Creates/changes size of the image buffer where we receive the images to process. More...
 
EMSCRIPTEN_KEEPALIVE t_str_jsonatagjs_detect ()
 Detect tags in image stored in the buffer (g_img_buf) More...
 

Detailed Description

Apriltag detection to be compile with emscripten.

See also
documentation in apriltag_js.h

Uses the apriltaf library; exposes a simple interface for a web app to use apriltags once it is compiled to WASM using emscripten

Copyright (C) Wiselab CMU.

Date
Nov, 2019

Function Documentation

◆ atagjs_destroy()

EMSCRIPTEN_KEEPALIVE int atagjs_destroy ( )

Releases resources.

Returns
0=success

◆ atagjs_detect()

EMSCRIPTEN_KEEPALIVE t_str_json* atagjs_detect ( )

Detect tags in image stored in the buffer (g_img_buf)

Returns
pointer to str_json structure. The data in this memory location must be consumed before the next call to detect()
Warning
caller is responsible for putting grayscale image pixels in the input buffer (g_img_buf)
caller should not release return pointer (it's reused at every detect() call); data returned must be consumed before the next call to detect()

◆ atagjs_init()

EMSCRIPTEN_KEEPALIVE int atagjs_init ( )

Init the apriltag detector with given family and default options default options: quad_decimate=2.0; quad_sigma=0.0; nthreads=1; refine_edges=1; return_pose=1.

See also
set_detector_options for meaning of options
Returns
0=success; -1 on failure

◆ atagjs_set_detector_options()

EMSCRIPTEN_KEEPALIVE int atagjs_set_detector_options ( float  decimate,
float  sigma,
int  nthreads,
int  refine_edges,
int  max_detections,
int  return_pose,
int  return_solutions 
)

Sets the given detector options.

Parameters
decimateDecimate input image by this factor
sigmaApply low-pass blur to input; negative sharpens
nthreadsUse this many CPU threads
refine_edgesSpend more time trying to align edges of tags
max_detectionsMaximum number of detections to return (0=no max)
return_poseDetect returns pose of detected tags (0=does not return pose; returns pose otherwise)
return_solutionsDetect returns details about both solutions of the pose estimation, if available
Returns
0=success

◆ atagjs_set_img_buffer()

EMSCRIPTEN_KEEPALIVE uint8_t* atagjs_set_img_buffer ( int  width,
int  height,
int  stride 
)

Creates/changes size of the image buffer where we receive the images to process.

Parameters
widthWidth of the image
heightHeight of the image
strideHow many pixels per row (=width typically)
Returns
the pointer to the image buffer
Warning
caller of detect is responsible for putting grayscale image pixels in this buffer

◆ atagjs_set_pose_info()

EMSCRIPTEN_KEEPALIVE int atagjs_set_pose_info ( double  fx,
double  fy,
double  cx,
double  cy 
)

Sets camera intrinsics (in pixels) for tag pose estimation.

Parameters
fxx focal lenght in pixels
fyy focal lenght in pixels
cxx principal point in pixels
cyy principal point in pixels
Returns
0=success