Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5,737 changes: 2,995 additions & 2,742 deletions build/artoolkitNFT.debug.js

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions build/artoolkitNFT.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/artoolkitNFT_wasm.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions emscripten/ARBindEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ EMSCRIPTEN_BINDINGS(constant_bindings) {
function("detectNFTMarker", &detectNFTMarker);
function("getNFTMarker", &getNFTMarkerInfo);

/* 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 */
function("setDebugMode", &setDebugMode);
function("getDebugMode", &getDebugMode);
Expand Down
39 changes: 31 additions & 8 deletions emscripten/ARToolKitJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

#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 arController {
int id;

Expand All @@ -47,6 +54,8 @@ struct arController {
int surfaceSetCount = 0; // Running NFT marker id
AR2SurfaceSetT *surfaceSet[PAGES_MAX];
std::unordered_map<int, AR2SurfaceSetT*> surfaceSets;
// nftMarker struct inside arController
nftMarker nft;

ARdouble nearPlane = 0.0001;
ARdouble farPlane = 1000.0;
Expand Down Expand Up @@ -261,7 +270,7 @@ extern "C" {
}

int loadNFTMarker(arController *arc, int surfaceSetCount, const char* datasetPathname) {
int i, pageNo;
int i, pageNo, numIset;
KpmRefDataSet *refDataSet;

KpmHandle *kpmHandle = arc->kpmHandle;
Expand Down Expand Up @@ -294,6 +303,17 @@ extern "C" {
if ((arc->surfaceSet[surfaceSetCount] = ar2ReadSurfaceSet(datasetPathname, "fset", NULL)) == NULL ) {
ARLOGe("Error reading data from %s.fset\n", datasetPathname);
}

numIset = arc->surfaceSet[surfaceSetCount]->surface[0].imageSet->num;
arc->nft.width_NFT = arc->surfaceSet[surfaceSetCount]->surface[0].imageSet->scale[0]->xsize;
arc->nft.height_NFT = arc->surfaceSet[surfaceSetCount]->surface[0].imageSet->scale[0]->ysize;
arc->nft.dpi_NFT = arc->surfaceSet[surfaceSetCount]->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);

ARLOGi(" Done.\n");

if (surfaceSetCount == PAGES_MAX) exit(-1);
Expand Down Expand Up @@ -428,27 +448,30 @@ extern "C" {
return 0;
}




/*****************
* Marker loading *
*****************/

int addNFTMarker(int id, std::string datasetPathname) {
if (arControllers.find(id) == arControllers.end()) { return -1; }
nftMarker addNFTMarker(int id, std::string datasetPathname) {
nftMarker nft;
if (arControllers.find(id) == arControllers.end()) { return nft; }
arController *arc = &(arControllers[id]);

// Load marker(s).
int patt_id = arc->surfaceSetCount;
if (!loadNFTMarker(arc, patt_id, datasetPathname.c_str())) {
ARLOGe("ARToolKitJS(): Unable to set up NFT marker.\n");
return -1;
return nft;
}

arc->surfaceSetCount++;

return patt_id;
nft.id_NFT = patt_id;
nft.width_NFT = arc->nft.width_NFT;
nft.height_NFT = arc->nft.height_NFT;
nft.dpi_NFT = arc->nft.dpi_NFT;

return nft;
}

/**********************
Expand Down
12 changes: 6 additions & 6 deletions js/artoolkitNFT.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
this._bwpointer = undefined;
this._lumaCtx = undefined;

this.version = '0.6.4';
this.version = '0.7.0';
console.info('JsartoolkitNFT ', this.version);

if (typeof cameraPara === 'string') {
Expand Down Expand Up @@ -333,9 +333,9 @@
ARControllerNFT.prototype.loadNFTMarker = function (markerURL, onSuccess, onError) {
var self = this;
if (markerURL) {
return artoolkit.addNFTMarker(this.id, markerURL, function (id) {
self.nftMarkerCount = id + 1;
onSuccess(id);
return artoolkit.addNFTMarker(this.id, markerURL, function (nft) {
self.nftMarkerCount = nft.id + 1;
onSuccess(nft);
}, onError);
} else {
if (onError) {
Expand Down Expand Up @@ -972,8 +972,8 @@
ajax(url + '.fset', filename1, function () {
ajax(url + '.iset', filename2, function () {
ajax(url + '.fset3', filename3, function () {
var id = Module._addNFTMarker(arId, prefix);
if (callback) callback(id);
var nftMarker = Module._addNFTMarker(arId, prefix);
if (callback) callback(nftMarker);
}, function (errorNumber) { if (onError) onError(errorNumber); });
}, function (errorNumber) { if (onError) onError(errorNumber); });
}, function (errorNumber) { if (onError) onError(errorNumber); });
Expand Down
7 changes: 4 additions & 3 deletions js/artoolkitNFT.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ function load (msg) {
markerResult = {type: "found", matrixGL_RH: JSON.stringify(ev.data.matrixGL_RH), proj: JSON.stringify(cameraMatrix)};
});

ar.loadNFTMarker(msg.marker, function (markerId) {
ar.trackNFTMarkerId(markerId);
console.log("loadNFTMarker -> ", markerId);
ar.loadNFTMarker(msg.marker, function (nft) {
ar.trackNFTMarkerId(nft.id);
console.log("loadNFTMarker -> ", nft.id);
console.log("nftMarker struct: ", nft);
postMessage({ type: 'endLoading', end: true }),
function (err) {
console.error('Error in loading marker on Worker', err);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kalwalt/jsartoolkit-nft",
"version": "0.6.4",
"version": "0.7.0",
"main": "build/artoolkitNFT_wasm.js",
"browser": "build/artoolkitNFT_wasm.js",
"description": "Emscripten port of ARToolKit5 to JavaScript. It is a lighter version of Jsartoolkit5 with only NFT markerless support",
Expand Down
2 changes: 1 addition & 1 deletion tools/makem.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var arguments = process.argv;
for (var j = 2; j < arguments.length; j++) {
if (arguments[j] == '--no-libar') {
NO_LIBAR = true;
console.log('Building jsartoolkit5 with --no-libar option, libar will be preserved.');
console.log('Building jsartoolkitNFT with --no-libar option, libar will be preserved.');
};
}

Expand Down