-
Notifications
You must be signed in to change notification settings - Fork 20
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
implementing NFT with threading support with emscripten #2
base: fixing-nft
Are you sure you want to change the base?
Conversation
With the last commit i get this error:
what does it means? the matrix is not filled in the right way? look:
the trans is a 3 * 4 as you can see in the code: jsartoolkit5/emscripten/ARToolKitJS.cpp Lines 104 to 128 in 41eb40a
|
from this stackoverflow article mrdoob comment:
|
The NFT marker is detected, i see the scan in the console, but the sphere is not displayed. I will see this issue in the next days. |
If it is calculating a determinant, it is looking something like a scaling factor. If I am not wrong should be applicable only to square matrices. Is |
@kalwalt |
I will try to check the code these days to see if I spot something. Apparently the I want to get and idea what the target of the threading is. At least one of the targeted functions appears to be If I understood correctly, I would say it makes sense to run a threading over that part. |
Unfortunately I'm not very skilled in math, biìut looking in the code it should be the pose matrix?
I don't think, it was part of the previous code, i will delete it.
i think i have implemented as in mainLoop in the nftSimple example: but the data after this routine pass trough |
emscripten/ARToolKitJS.cpp
Outdated
if (flag > -1) { | ||
|
||
//ARLOGi("flag is: %d\n", arc->detectedPage); | ||
if (pageNo >= 0 && pageNo == arc->detectedPage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem is this we do not pass any data to the EM_ASM
if i change the variable in the conditional for example:
if (pageNo >= 0)
we get data but with that Threejs error, and the sphere appear and disappears. MAybe we should use another condition or what else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't remember why i put this:
if (pageNo >= 0 && pageNo == arc->detectedPage) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it should be
if (arc->detectedPage >= -1) {
//// or better
if (arc->detectedPage > -1) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather ask why appears and disappears. As you put it, it is a hack that might work for some but not all cases. I would prefer to understand why pageNo should be as condition.
However, this might not have sense: pageNo >= 0 && pageNo == arc->detectedPage
. I can see some contradictory behaviour there.
If you leave it as arc->detectedPage > -1
, does it mean that pageNo >= 0
? For what I read from the code, detectedPage
was a sort of flag for different states. What meant -1 status for detectedPage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
if (pageNo >= 0 && arc->detectedPage SOMETHING -1) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the flagging I found for detectedPage:
int detectedPage = -2; // -2 Tracking not inited, -1 tracking inited OK, >= 0 tracking online on page.
@kalwalt kpmResultNum markersNFT struct The code apparently never bother about detecting whether there was a variation of the values of the transformation matrix : it apparently just rectify at every frame, no matter the values. So if I understand correctly that part of the script always runs. It is likely necessary: if I am not wrong the detector algorithm needs to rectify the test image (frame) in order to compare the found points in a similar orientation, position, etc than in the training image before declaring a good matching. Once the points have been detected, the homographic correction might be used to correct the volume projection over the target area in the test image. There is something similar happening with marker-based detection, @kalwalt, but the training marker is deployed differently and the algos might be easier. However, this is NOT a step that might require threading. A for-loop will do. I think there are other parts that will be more suitable to, to mention:
|
However now that I see it you might not have access to those methods though... hmmmm.... And they might be already optimized. So probably the point comparison might be a good target, as well as the creation of the strucs when a painful for-loop is implemented. Can you rather work on a simpler approach by for example making some for-loops more threaded instead? See that those for-loops are almost always there, for every frame. Just a suggestion. |
Contact you these days? Take care! |
@evaristoc thanks for the feedback! I have not time to answer to all the questions/topics but I want to make an observation: the |
296fc2e
to
218cb8f
Compare
With the latest commits i got always the message |
@evaristoc @nicolocarpignoli It seems that But there are other refinement in the code to do, and other issues to solve... |
Unfortunately this not works with Firefox: Current environment does not support SharedArrayBuffer, pthreads are not available! artoolkitNft.min.js:formatted:7495
ExitStatus: Program terminated with exit(-1) |
SharedArrayBuffer is supported by Firefox but is off by default for now as a result of Spectre. Should be available again to all main branch here shortly, now that Microsoft and Intel seem to have worked out a fix. For now you can turn it on.
… On Jul 27, 2019, at 3:06 PM, Walter Perdan ***@***.***> wrote:
Unfortunately this not works with Firefox:
Current environment does not support SharedArrayBuffer, pthreads are not available! artoolkitNft.min.js:formatted:7495
ExitStatus: Program terminated with exit(-1)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@nicolocarpignoli @evaristoc @ThorstenBux @shawmakesmusic now it works!! it was a problem of scaling the model and repositioning it !! |
I should also test the binary version of the models, probably more efficient in loading time, and needs to test also with mobile devices... |
@kalwalt Great! |
@kalwalt Unfortunately I didn't have time in August and September, but in October I will have a lot more time for projects. The last thing I was doing was trying to read the jpeg image because the current implementation of the marker creator is focused to local, not web, so I can't read some properties of the jpeg file using JavaScript. Maybe @ThorstenBux can help me to understand the data inside the iset and fset files. |
@Carnaux I imagined you were busy, but no problem! Unfortunately i have not so much time but I will try to move forward. regarding the problem for jpeg images I will begin to look at the problem, maybe I will open a specific issue in your repository. |
@kalwalt I will open one and describe what is needed and what I was trying. |
@Carnaux just opened one right now! |
@kalwalt are you able to host a version of it on Github.io? It would be a great way to test quickly with different mobile phones too. If you don't know how to to that just ask i can help you it's simple |
@nicolocarpignoli I can do it. and this is a good idea. 😄 |
@nicolocarpignoli with Github.io you can only host the master or the gh-pages or docs folder, you can not host other branch apart them. I will host on my https://github.com/kalwalt/kalwalt-interactivity-AR. I will do tomorrow as now is too late and i am very tired. |
yes no worries host it wherever you want :) |
@nicolocarpignoli and everybody here... i hosted one of the examples (CesiumMan) at my page https://kalwalt.github.io/kalwalt-interactivity-AR/nft_threads_cesium.html will host also the other examples when i will have time. |
i added some other example to test to my https://kalwalt.github.io/kalwalt-interactivity-AR/ if someone want to try. |
The asm.js issue: Edit: but i tested on my https://kalwalt.github.io/kalwalt-interactivity-AR/ |
I adapted the code to emscripten emsdk 3.1.20, the code can be build but when i run the nft_threejs example the camera parameter can not be corrected loaded. For precision: it load the binary file but unfortunately this is not sufficient. That's very strange, maybe something related to emscripten pthread? One possible issue is the loadCamera function in the --pre-js, if we remove it from artoolkit.api.js and create the necessary code for loading outside maybe it can be solved? |
* Transfer data | ||
*/ | ||
|
||
void transferDataToHeap(int id, ARUint8 *data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I m not sure but it seems that is not correct, i should check and maybe i will restore it.
//FLAGS += ' -s ERROR_ON_UNDEFINED_SYMBOLS=0'; | ||
//FLAGS += ' -s NO_BROWSER=1 '; // for 20k less | ||
FLAGS += ' --memory-init-file 0 '; // for memless file | ||
FLAGS += ' -s BINARYEN_TRAP_MODE=clamp' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with newer emscripten (upstream) version it's not needed anymore.
@@ -117,10 +115,10 @@ var FLAGS = '' + OPTIMIZE_FLAGS; | |||
FLAGS += ' -Wno-warn-absolute-paths '; | |||
FLAGS += ' -s TOTAL_MEMORY=' + MEM + ' '; | |||
FLAGS += ' -s USE_ZLIB=1'; | |||
FLAGS += ' -s USE_LIBJPEG=1 '; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't needed anymore to include libjpeg source code since it's embedded inside Emscripten, just adding this flag...
In this PR i test the NFT with threading support. Basically i modified some functions in
ARToolKitJS.cpp
with the threading methods intrackingSub.c
:The project is not finished, they are some modifications to do... but even if it is not finished, i got 80-90 fps and 20-25 fps while detecting the NFT marker/image.
Note: not all the examples will works, i'm testing now only the
nft_threejs.html
example.I'm developing for now only the minified version, i not added the Pthread support to the debug version due to this issue explained in this emscripten article:
When it will be ready, will be merged in PR #1
to do list:
Invalid asm.js: Invalid member of stdlib
Note:
If someone want to try and test the code you can go to https://kalwalt.github.io/kalwalt-interactivity-AR/
But Please read carefully this before:
You need to enable the SharedArrayBuffer option in your browser. This was disabled due to Spectre issue read this article !!!
Update 16/2/2023
updated the code to Emscripten emsdk 3.1.20,
-s USE_LIBJPEG=1
transferDataToHeap
methodAnyway, as said in this comment the code fails to load the camera parameter, and then fails to detect and track the NFT marker.