Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
98fda9a
packages upgrade
kalwalt Apr 19, 2021
499abf4
webpack upgrade
kalwalt Apr 19, 2021
0745729
ar-js-org package version 0.1.0
kalwalt Apr 20, 2021
4dc7f3e
simplify _copyImageToHeap
kalwalt May 11, 2021
a7da326
added logs for debug
kalwalt May 16, 2021
8234a0d
upgrading packages
kalwalt Nov 4, 2021
6985765
removing yarn.lock file and logs
kalwalt Nov 5, 2021
19e6136
Merge branch 'master' into ar-js-org
kalwalt Nov 5, 2021
6e397e5
Merge pull request #10 from AR-js-org/remove-portrait-handling
kalwalt Nov 5, 2021
a99fce5
improved Readme
kalwalt Nov 5, 2021
c3fb3ec
Merge branch 'ar-js-org' into remove-portrait-handling
kalwalt Nov 5, 2021
dbea63a
re-install packages
kalwalt Nov 5, 2021
71eb047
new dist lib
kalwalt Nov 5, 2021
aa21c37
version 0.1.1
kalwalt Nov 5, 2021
f5ac352
added MEMORY_GROWTH option
kalwalt Nov 16, 2021
4dc524b
replace deprecated EXTRA_EXPORTED_RUNTIME_METHODS
kalwalt Nov 16, 2021
8980384
new dist lib version 0.1.2
kalwalt Nov 16, 2021
618e3eb
changes in _copyImageToHeap (portrait mode)
kalwalt Nov 18, 2021
42f7a10
version 0.1.3
kalwalt Feb 15, 2022
f9573e8
adding more barcode types
kalwalt Oct 25, 2022
87bfc9f
implementing getNFTData function
kalwalt Oct 25, 2022
ecae459
other Matrix code types
kalwalt Oct 28, 2022
be722f6
dist lib
kalwalt Oct 28, 2022
a5909e4
version 0.2.0
kalwalt Oct 28, 2022
e777d07
testing type definitions see #20
kalwalt Jan 16, 2023
601525e
types entry in package.json
kalwalt Jan 20, 2023
ce3708b
fix for initWithDimensions
kalwalt Jan 23, 2023
32a0813
improved typedefs
kalwalt Jan 24, 2023
de791d3
all inner properties declared private
kalwalt Jan 24, 2023
35681ad
version 0.3.0
kalwalt Jan 24, 2023
5d1331b
removed scoped name
kalwalt Feb 10, 2023
b6020f5
removed @ar-js-org
kalwalt Feb 10, 2023
e682779
upgrading packages
kalwalt Feb 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ node_modules/
.cache
.vscode
.DS_Store

# other files
src/artoolkit5/*.bc
dist/*.LICENSE.txt
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@

# artoolkit5-js

ES6 module port of [artoolkit5](https://github.com/artoolkitx/artoolkit5). Based on the (now defunct) original [Emscripten to JavaScript port](github.com/artoolkit/jsartoolkit5) and [improved](https://github.com/kalwalt/jsartoolkit5) by [Walter Perdan](https://github.com/kalwalt).
This is the artoolkit5-js fork for the AR.js project.

ES6 module port of [artoolkit5](https://github.com/artoolkitx/artoolkit5). Based on the (now defunct) original [Emscripten to JavaScript port](github.com/artoolkitx/jsartoolkit5) and [improved](https://github.com/kalwalt/jsartoolkit5) by [Walter Perdan](https://github.com/kalwalt).

This build is uses WASM for best possible performance and is designed to be (more or less) a drop-in replacement for the previous jsartoolkit5. Some parts of the previous API have been refactored to implement an async interface instead of the previous callback based interface.

## Installation

Install the module via NPM:
The **artoolkit5-js** package can be installed via NPM:
```
npm install artoolkit5-js
```
The module is built in UMD format and can be used in different environments:

### Browser
```
```html
<script src="/path/to/ARToolkit.js"></script>
```

### Node.js
```
```js
const ARToolkit = require('artoolkit5-js');
```

### ES6 Import
```
```js
import ARToolkit from 'artoolkit5-js';
```

Expand All @@ -34,7 +36,7 @@ import ARToolkit from 'artoolkit5-js';

First you need to create an instance of `ARController`:

```
```js
ARController.initWithDimensions(640, 480, '/data/camera_para.dat').then(controller => { ... });
```
This will create an ARController instance expecting source images of dimensions 640x480. The second parameter is a camera definition file which describes the characteristics of your image / video input device. If you don't know which file to use just use the default [camera_para.dat](https://github.com/andypotato/artoolkit5-js/blob/master/data/camera_para.dat) included with this repository.
Expand All @@ -45,13 +47,13 @@ There is an alternative initializer `initWithImage` available as convenience met

Next you need to load the marker files to track with your controller. In this example the pattern file for the "Hiro" marker is loaded:

```
```js
controller.artoolkit.addMarker(controller.id, '/data/hiro.patt').then(hiroMarkerId => { ... });
```

### 3) Start tracking

```
```js
// track with 60 FPS
const FPS = 60;

Expand Down Expand Up @@ -88,7 +90,7 @@ setInterval(() => {
## Other ARToolkit API methods

You can access all public ARToolkit methods and class constants like this:
```
```js
// for the full API documentation see
// https://github.com/artoolkit/artoolkit5
artoolkit.detectMarker( ... );
Expand All @@ -97,4 +99,4 @@ You can access all public ARToolkit methods and class constants like this:
```

## Current limitations
Due to time constraints this build does not implement NFT and multimarker support (yet). Adding support for both should be trivial though as all the groundwork has already been laid out. I will implement it once time allows but PRs are of course welcome!
Due to time constraints this build does not implement multimarker support (yet). Adding support should be trivial though as all the groundwork has already been laid out. I will implement it once time allows but PRs are of course welcome!
10 changes: 2 additions & 8 deletions dist/ARToolkit.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions lib/ARBindEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ using namespace emscripten;

EMSCRIPTEN_BINDINGS(constant_bindings) {

register_vector<nftMarker>("nftMarkers");

function("setup", &setup);
function("teardown", &teardown);

Expand Down Expand Up @@ -35,6 +37,14 @@ EMSCRIPTEN_BINDINGS(constant_bindings) {
function("getMultiEachMarker", &getMultiEachMarkerInfo);
function("getMarker", &getMarkerInfo);
function("getNFTMarker", &getNFTMarkerInfo);
function("getNFTData", &getNFTData);

/* nft marker struct */
value_object<nftMarker>("nftMarker")
.field("id", &nftMarker::id_NFT)
.field("width", &nftMarker::width_NFT)
.field("height", &nftMarker::height_NFT)
.field("dpi", &nftMarker::dpi_NFT);


/* AR Toolkit C APIS */
Expand Down Expand Up @@ -128,6 +138,10 @@ EMSCRIPTEN_BINDINGS(constant_bindings) {
constant("AR_MATRIX_CODE_4x4", AR_MATRIX_CODE_4x4 + 0);
constant("AR_MATRIX_CODE_4x4_BCH_13_9_3", AR_MATRIX_CODE_4x4_BCH_13_9_3 + 0);
constant("AR_MATRIX_CODE_4x4_BCH_13_5_5", AR_MATRIX_CODE_4x4_BCH_13_5_5 + 0);
constant("AR_MATRIX_CODE_5x5_BCH_22_12_5", AR_MATRIX_CODE_5x5_BCH_22_12_5 + 0);
constant("AR_MATRIX_CODE_5x5_BCH_22_7_7", AR_MATRIX_CODE_5x5_BCH_22_7_7 + 0);
constant("AR_MATRIX_CODE_5x5", AR_MATRIX_CODE_5x5 + 0);
constant("AR_MATRIX_CODE_6x6", AR_MATRIX_CODE_6x6 + 0);

constant("AR_LABELING_THRESH_MODE_MANUAL", AR_LABELING_THRESH_MODE_MANUAL + 0);
constant("AR_LABELING_THRESH_MODE_AUTO_MEDIAN", AR_LABELING_THRESH_MODE_AUTO_MEDIAN + 0);
Expand Down
53 changes: 45 additions & 8 deletions lib/ARToolKitJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@

#define PAGES_MAX 10 // Maximum number of pages expected. You can change this down (to save memory) or up (to accomodate more pages.)

struct nftMarker {
int id_NFT;
int width_NFT;
int height_NFT;
int dpi_NFT;
};
struct multi_marker {
int id;
ARMultiMarkerInfoT *multiMarkerHandle;
Expand Down Expand Up @@ -60,6 +66,10 @@ struct arController {
AR2SurfaceSetT *surfaceSet[PAGES_MAX];
std::unordered_map<int, AR2SurfaceSetT*> surfaceSets;

// nftMarker struct inside arController
nftMarker nft;
std::vector<nftMarker> nftMarkers;

ARdouble nearPlane = 0.0001;
ARdouble farPlane = 1000.0;

Expand Down Expand Up @@ -313,9 +323,30 @@ extern "C" {
if ((arc->surfaceSet[surfaceSetCount] = ar2ReadSurfaceSet(datasetPathname, "fset", NULL)) == NULL ) {
ARLOGe("Error reading data from %s.fset\n", datasetPathname);
}
ARLOGi(" Done.\n");

if (surfaceSetCount == PAGES_MAX) exit(-1);
// int surfaceSetCount = arc->surfaceSetCount;
int numIset = arc->surfaceSet[i]->surface[0].imageSet->num;
arc->nft.width_NFT =
arc->surfaceSet[i]->surface[0].imageSet->scale[0]->xsize;
arc->nft.height_NFT =
arc->surfaceSet[i]->surface[0].imageSet->scale[0]->ysize;
arc->nft.dpi_NFT =
arc->surfaceSet[i]->surface[0].imageSet->scale[0]->dpi;

ARLOGi("NFT num. of ImageSet: %i\n", numIset);
ARLOGi("NFT marker width: %i\n", arc->nft.width_NFT);
ARLOGi("NFT marker height: %i\n", arc->nft.height_NFT);
ARLOGi("NFT marker dpi: %i\n", arc->nft.dpi_NFT);

arc->nft.id_NFT = i;
arc->nft.width_NFT = arc->nft.width_NFT;
arc->nft.height_NFT = arc->nft.height_NFT;
arc->nft.dpi_NFT = arc->nft.dpi_NFT;
arc->nftMarkers.push_back(arc->nft);

ARLOGi(" Done.\n");

if (surfaceSetCount == PAGES_MAX)
exit(-1);

if (kpmSetRefDataSet(kpmHandle, refDataSet) < 0) {
ARLOGe("Error: kpmSetRefDataSet\n");
Expand All @@ -327,6 +358,13 @@ extern "C" {
return (TRUE);
}

nftMarker getNFTData(int id, int index) {
if (arControllers.find(id) == arControllers.end()) { return {}; }
arController *arc = &(arControllers[id]);
// get marker(s) nft data.
return arc->nftMarkers.at(index);
}

/***************
* Set Log Level
****************/
Expand Down Expand Up @@ -902,12 +940,11 @@ extern "C" {
arController *arc = &(arControllers[id]);

// Convert video frame to AR2VideoBufferT
AR2VideoBufferT buff = {0};
buff.buff = arc->videoFrame;
buff.fillFlag = 1;

buff.buffLuma = arc->videoLuma;
AR2VideoBufferT buff = {0};
buff.buff = arc->videoFrame;
buff.fillFlag = 1;

buff.buffLuma = arc->videoLuma;

return arDetectMarker( arc->arhandle, &buff);
}
Expand Down
Loading