Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
- new OEF OneEuroFilter feature
 - fix for issue #286 and #300
 - pkg upgrade
  • Loading branch information
kalwalt committed Mar 28, 2023
2 parents 9b75851 + 5bb7fa1 commit e900b13
Show file tree
Hide file tree
Showing 24 changed files with 471 additions and 157 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
${{ runner.os }}-node-
- name: Set output
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
run: echo name=tag::${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
- name: Check output
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
Expand All @@ -45,7 +45,7 @@ jobs:
- run: npm install
- run: docker run -dit --name emscripten -v $(pwd):/src emscripten/emsdk:3.1.32 bash
- run: docker exec emscripten npm run build
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist
Expand All @@ -69,11 +69,14 @@ jobs:
build/artoolkitNFT_wasm.simd.js
build/artoolkitNFT.debug.js
build/artoolkitNFT.min.js
js/artoolkitNFT_ES6_custom.worker.js
js/artoolkitNFT_ES6_gray.worker.js
js/artoolkitNFT_ES6.worker.js
js/artoolkitNFT_multi_ES6.worker.js
js/artoolkitNFT.api.js
js/artoolkitNFT_ES6.api.js
js/artoolkitNFT.worker.js
js/artoolkitNFT.embed_ES6_worker.js
js/artoolkitNFT.multi_worker.js
dist/ARToolkitNFT.js
dist/ARToolkitNFT_simd.js
52 changes: 26 additions & 26 deletions build/artoolkitNFT.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -89883,6 +89883,32 @@ function std____2__basic_string_char_2c_20std____2__char_traits_char__2c_20std__
return $0;
}

function matrixLerp($0, $1, $2) {
var $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0;
$8 = +Math_fround(Math_fround(1) - $2);
$9 = +$2;
label$1: while (1) {
label$2: {
$3 = 0;
if (($4 | 0) == 3) {
break label$2;
}
while (1) if (($3 | 0) == 4) {
$4 = $4 + 1 | 0;
continue label$1;
} else {
$5 = $3 << 3;
$6 = $4 << 5;
$7 = $5 + ($6 + $1 | 0) | 0;
HEAPF64[$7 >> 3] = $8 * HEAPF64[($0 + $6 | 0) + $5 >> 3] + HEAPF64[$7 >> 3] * $9;
$3 = $3 + 1 | 0;
continue;
}
}
break;
}
}

function int_20vision__MaxIndex8_float__28float_20const__29($0) {
var $1 = 0;
$1 = HEAPF32[$0 + 4 >> 2] > HEAPF32[$0 >> 2];
Expand Down Expand Up @@ -90432,32 +90458,6 @@ function std____2____hash_node_destructor_std____2__allocator_std____2____hash_n
}
}

function matrixLerp($0, $1, $2) {
var $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0;
$9 = +$2;
label$1: while (1) {
label$2: {
$3 = 0;
if (($4 | 0) == 3) {
break label$2;
}
while (1) if (($3 | 0) == 4) {
$4 = $4 + 1 | 0;
continue label$1;
} else {
$5 = $3 << 3;
$6 = $4 << 5;
$7 = $5 + ($6 + $1 | 0) | 0;
$8 = HEAPF64[$7 >> 3];
HEAPF64[$7 >> 3] = $8 + (HEAPF64[($0 + $6 | 0) + $5 >> 3] - $8) / $9;
$3 = $3 + 1 | 0;
continue;
}
}
break;
}
}

function __cxxabiv1____base_class_type_info__has_unambiguous_public_base_28__cxxabiv1____dynamic_cast_info__2c_20void__2c_20int_29_20const($0, $1, $2, $3) {
var $4 = 0, $5 = 0;
$5 = HEAP32[$0 + 4 >> 2];
Expand Down
4 changes: 2 additions & 2 deletions build/artoolkitNFT.min.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/artoolkitNFT_ES6_wasm.simd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/artoolkitNFT_embed_ES6_wasm.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.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ARToolkitNFT.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ARToolkitNFT_simd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion emscripten/ARToolKitJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ extern "C"
{
for (int j = 0; j < 4; j++)
{
dst[i][j] = dst[i][j] + (src[i][j] - dst[i][j]) / interpolationFactor;
dst[i][j] = (1 - interpolationFactor) * src[i][j] + dst[i][j] * interpolationFactor;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion js/artoolkitNFT.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
this._bwpointer = undefined;
this._lumaCtx = undefined;

this.version = '1.4.0';
this.version = '1.4.1';
console.info('JsartoolkitNFT ', this.version);
console.warn("This library is deprecated, use the ES6 version instead!! It will be removed in a future release.")

Expand Down
34 changes: 33 additions & 1 deletion js/artoolkitNFT.embed_ES6_worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import ARToolkitNFT from "../build/artoolkitNFT_embed_ES6_wasm.js";
// Import OneEuroFilter class into the worker.
import { OneEuroFilter } from "./one-euro-filter-ES6.js"

self.onmessage = function (e) {
var msg = e.data;
Expand All @@ -20,6 +22,26 @@ var ar = null;
var markerResult = null;
var marker;

const WARM_UP_TOLERANCE = 5;
let tickCount = 0;

// initialize the OneEuroFilter
var oef = true;
let filterMinCF = 0.0001;
let filterBeta = 0.01;
const filter = new OneEuroFilter({ minCutOff: filterMinCF, beta: filterBeta });

function oefFilter(matrixGL_RH) {
tickCount += 1;
var mat;
if (tickCount > WARM_UP_TOLERANCE) {
mat = filter.filter(Date.now(), matrixGL_RH);
} else {
mat = matrixGL_RH;
}
return mat;
}

async function load(msg) {
const arTK = await ARToolkitNFT();
//self.addEventListener("artoolkitNFT-loaded", function () {
Expand All @@ -32,12 +54,22 @@ async function load(msg) {
var cameraMatrix = ar.getCameraMatrix();

ar.addEventListener("getNFTMarker", function (ev) {
var mat;
if (oef == true) {
mat = oefFilter(ev.data.matrixGL_RH)
} else {
mat = ev.data.matrixGL_RH
}
markerResult = {
type: "found",
matrixGL_RH: JSON.stringify(ev.data.matrixGL_RH),
matrixGL_RH: JSON.stringify(mat),
};
});

ar.addEventListener("lostNFTMarker", function (ev) {
filter.reset();
});

ar.loadNFTMarker(msg.marker, function (id) {
ar.trackNFTMarkerId(id);
let marker = ar.getNFTData(id, 0);
Expand Down
28 changes: 23 additions & 5 deletions js/artoolkitNFT.multi_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if (browser == "Apple Safari") {
} else {
importScripts("../build/artoolkitNFT_wasm.simd.js");
}
// Import OneEuroFilter class into the worker.
importScripts("./one-euro-filter.js");

self.onmessage = function (e) {
var msg = e.data;
Expand All @@ -50,6 +52,14 @@ var ar = null;
var markerResult = null;
var marker1, marker2, marker3;

const WARM_UP_TOLERANCE = 5;
let tickCount = 0;

// initialize the OneEuroFilter
let filterMinCF = 0.0001;
let filterBeta = 0.01;
const filter = new OneEuroFilter({minCutOff: filterMinCF, beta: filterBeta});

function load(msg) {
self.addEventListener("artoolkitNFT-loaded", function () {
console.debug("Loading marker at: ", msg.marker);
Expand All @@ -59,11 +69,19 @@ function load(msg) {
var cameraMatrix = ar.getCameraMatrix();

ar.addEventListener("getNFTMarker", function (ev) {
markerResult = {
type: "found",
index: JSON.stringify(ev.data.index),
matrixGL_RH: JSON.stringify(ev.data.matrixGL_RH),
};
tickCount += 1;
if (tickCount > WARM_UP_TOLERANCE) {
var mat = filter.filter(Date.now(), ev.data.matrixGL_RH);
markerResult = {
type: "found",
index: JSON.stringify(ev.data.index),
matrixGL_RH: JSON.stringify(mat),
};
}
});

ar.addEventListener("lostNFTMarker", function(ev) {
filter.reset();
});

ar.loadNFTMarkers(msg.marker, function (ids) {
Expand Down
26 changes: 22 additions & 4 deletions js/artoolkitNFT.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if (browser == "Apple Safari") {
} else {
importScripts("../build/artoolkitNFT_wasm.simd.js");
}
// Import OneEuroFilter class into the worker.
importScripts("./one-euro-filter.js");

self.onmessage = function (e) {
var msg = e.data;
Expand All @@ -50,6 +52,14 @@ var ar = null;
var markerResult = null;
var marker;

const WARM_UP_TOLERANCE = 5;
let tickCount = 0;

// initialize the OneEuroFilter
let filterMinCF = 0.0001;
let filterBeta = 0.01;
const filter = new OneEuroFilter({minCutOff: filterMinCF, beta: filterBeta});

function load(msg) {
self.addEventListener("artoolkitNFT-loaded", function () {
console.debug("Loading marker at: ", msg.marker);
Expand All @@ -59,10 +69,18 @@ function load(msg) {
var cameraMatrix = ar.getCameraMatrix();

ar.addEventListener("getNFTMarker", function (ev) {
markerResult = {
type: "found",
matrixGL_RH: JSON.stringify(ev.data.matrixGL_RH),
};
tickCount += 1;
if (tickCount > WARM_UP_TOLERANCE) {
var mat = filter.filter(Date.now(), ev.data.matrixGL_RH);
markerResult = {
type: "found",
matrixGL_RH: JSON.stringify(mat),
};
}
});

ar.addEventListener("lostNFTMarker", function(ev) {
filter.reset();
});

ar.loadNFTMarker(msg.marker, function (id) {
Expand Down
2 changes: 1 addition & 1 deletion js/artoolkitNFT_ES6.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ARControllerNFT {
this._bwpointer = undefined;
this._lumaCtx = undefined;

this.version = '1.4.0';
this.version = '1.4.1';
console.info('JsartoolkitNFT ', this.version);

if (typeof cameraPara === 'string') {
Expand Down
66 changes: 56 additions & 10 deletions js/artoolkitNFT_ES6.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if (browser == "Apple Safari") {
} else {
importScripts("../dist/ARToolkitNFT_simd.js");
}
// Import OneEuroFilter class into the worker.
importScripts("./one-euro-filter.js");

self.onmessage = function (e) {
var msg = e.data;
Expand All @@ -49,6 +51,29 @@ var ar = null;
var markerResult = null;
var marker;

const WARM_UP_TOLERANCE = 5;
let tickCount = 0;

// initialize the OneEuroFilter
var oef = true;
let filterMinCF = 0.0001;
let filterBeta = 0.01;
const filter = new OneEuroFilter({
minCutOff: filterMinCF,
beta: filterBeta
});

function oefFilter(matrixGL_RH) {
tickCount += 1;
var mat;
if (tickCount > WARM_UP_TOLERANCE) {
mat = filter.filter(Date.now(), matrixGL_RH);
} else {
mat = matrixGL_RH;
}
return mat;
}

function load(msg) {
console.debug("Loading marker at: ", msg.marker);

Expand All @@ -57,24 +82,43 @@ function load(msg) {
var cameraMatrix = ar.getCameraMatrix();

ar.addEventListener("getNFTMarker", function (ev) {
var mat;
if (oef == true) {
mat = oefFilter(ev.data.matrixGL_RH)
} else {
mat = ev.data.matrixGL_RH
}
markerResult = {
type: "found",
matrixGL_RH: JSON.stringify(ev.data.matrixGL_RH),
matrixGL_RH: JSON.stringify(mat),
};
});

ar.addEventListener("lostNFTMarker", function (ev) {
filter.reset();
});

ar.loadNFTMarker(msg.marker, function (id) {
ar.trackNFTMarkerId(id);
let marker = ar.getNFTData(ar.id, 0);
console.log("nftMarker data: ", marker);
postMessage({ type: "markerInfos", marker: marker });
postMessage({
type: "markerInfos",
marker: marker
});
console.log("loadNFTMarker -> ", id);
postMessage({ type: "endLoading", end: true });
postMessage({
type: "endLoading",
end: true
});
}).catch(function (err) {
console.log("Error in loading marker on Worker", err);
});

postMessage({ type: "loaded", proj: JSON.stringify(cameraMatrix) });
postMessage({
type: "loaded",
proj: JSON.stringify(cameraMatrix)
});
};

var onError = function (error) {
Expand All @@ -85,10 +129,10 @@ function load(msg) {

// we cannot pass the entire ARControllerNFT, so we re-create one inside the Worker, starting from camera_param
ARToolkitNFT.ARControllerNFT.initWithDimensions(
msg.pw,
msg.ph,
msg.camera_para
)
msg.pw,
msg.ph,
msg.camera_para
)
.then(onLoad)
.catch(onError);
}
Expand All @@ -103,8 +147,10 @@ function process() {
if (markerResult) {
postMessage(markerResult);
} else {
postMessage({ type: "not found" });
postMessage({
type: "not found"
});
}

next = null;
}
}
Loading

0 comments on commit e900b13

Please sign in to comment.