Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing artoolkitNFT as a global variable (part 2) #283

Merged
merged 12 commits into from
Feb 27, 2023

Conversation

kalwalt
Copy link
Member

@kalwalt kalwalt commented Feb 23, 2023

List of Features/changes

This PR is a continuation from # 276

  • removed frameMalloc, dataHeap and all related code
  • new method passVideoData()
  • remove matrixCopy() see issue matrixCopy is not required #284
  • completely removing artoolkitNFT as a global variable

@kalwalt
Copy link
Member Author

kalwalt commented Feb 23, 2023

Node tests fails because i haven't updated the artoolkit.api.js to reflect the new changes in the ARToolKitJS.cpp code. i will fix this in another commit.
At this point the code can detect and track the pinball image, but i note a worste performance, probably because we are transferring videoFrame data and and videoLuma more times (see detectMarker, detectNFTMarker and getNFTMarkerInfo), we should instead avoid this and pass only one time the data. For this i created the passVideoData method, but i haven't yet created the typescript/js wrapper for this.

emscripten/ARToolKitJS.cpp Outdated Show resolved Hide resolved
@kalwalt kalwalt force-pushed the feature-remove-global-variable branch from 7471ad3 to f922f99 Compare February 23, 2023 22:42
@kalwalt
Copy link
Member Author

kalwalt commented Feb 24, 2023

While testing the ARToolkitNFT_ES6_gray_example.html example i got:

ARToolkitNFT_simd.js:2 Uncaught RangeError: offset is out of bounds
    at Uint8Array.set (<anonymous>)
    at A.value (ARToolkitNFT_simd.js:2:1454854)
    at A.value (ARToolkitNFT_simd.js:2:1449673)
    at A.value (ARToolkitNFT_simd.js:2:1448320)
    at process (artoolkitNFT_ES6_gray.worker.js:118:8)
    at self.onmessage (artoolkitNFT_ES6_gray.worker.js:44:7)
value @ ARToolkitNFT_simd.js:2
value @ ARToolkitNFT_simd.js:2
value @ ARToolkitNFT_simd.js:2
process @ artoolkitNFT_ES6_gray.worker.js:118
self.onmessage @ artoolkitNFT_ES6_gray.worker.js:44

@@ -34,7 +34,7 @@
*
*/
import ARToolkitNFT from "./ARToolkitNFT_simd";
import ARControllerNFT from "./ARControllerNFT";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was exporting the wrong lib here! it wasn't using simd at all...

@@ -1,5 +1,5 @@
import ARToolkitNFT from "./ARToolkitNFT_simd";
import ARControllerNFT from "./ARControllerNFT";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

@@ -918,7 +918,7 @@ export default class ARControllerNFT implements AbstractARControllerNFT {
q += 4;
}
} else if (this.grayscaleEnabled == true) {
this.videoLuma.set(this.grayscaleSource);
Copy link
Member Author

@kalwalt kalwalt Feb 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can't understand why this will make fail, with an out bounds error. I will investigate.

@@ -918,7 +918,7 @@ export default class ARControllerNFT implements AbstractARControllerNFT {
q += 4;
}
} else if (this.grayscaleEnabled == true) {
this.videoLuma.set(this.grayscaleSource);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as bove.

@kalwalt
Copy link
Member Author

kalwalt commented Feb 27, 2023

I think i can delete these lines of code

declare global {
var artoolkitNFT: IARToolkitNFT;
}

and
let scope = typeof window !== "undefined" ? window : global;
scope.artoolkitNFT = this;

actually you can't use the artoolkitNFT global variable because is not correctly exported (attached) to the window object.
I will leave untouched the old code (the minified and other build libs...) but i think we can avoid the use of a global variable.

@kalwalt kalwalt merged commit f3660b9 into dev Feb 27, 2023
kalwalt added a commit that referenced this pull request Feb 27, 2023
@kalwalt kalwalt deleted the feature-remove-global-variable branch February 27, 2023 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant