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

Improving WebARKitLib with PnP algorithm #24

Merged
merged 48 commits into from
Apr 1, 2024
Merged

Improving WebARKitLib with PnP algorithm #24

merged 48 commits into from
Apr 1, 2024

Conversation

kalwalt
Copy link
Member

@kalwalt kalwalt commented Nov 2, 2023

This PR is based on changes in PR webarkit/WebARKitLib#23

@kalwalt kalwalt added enhancement New feature or request Emscripten / C / C++ all about Emscripten Typescript labels Nov 2, 2023
@kalwalt kalwalt self-assigned this Nov 2, 2023
@kalwalt kalwalt changed the title Improving Webarkitlib with PnP algorithm Improving WebARKitLib with PnP algorithm Nov 2, 2023
emscripten/WebARKitJS.cpp Outdated Show resolved Hide resolved
@kalwalt
Copy link
Member Author

kalwalt commented Nov 2, 2023

Another issue with the pose matrix, i receive always these values pose matrix : (12) [1, 0, 0, 1.88857625396e-312, 0, 1, 0, 6.780710231860827e-309, 0, 0, 1, 0] Maybe something is not correct in the computePose function.

@kalwalt
Copy link
Member Author

kalwalt commented Nov 16, 2023

i think the result from matrixGL_RH is not correct, look at these values, this is matrixGL_RH from jsartoolkitNFT:

matrixGL_RH: [0.04984269657942322, 0.0011028004165823837, 0.0037468644060579515, 0, -0.00015674864315588379, 0.048456810395189856, -0.012054592420455989, 0, -0.003895003003705642, 0.012004841145274035, 0.04830878467734379, 0, -5.418834804971434, -3.6673568534354173, -10.857604385997499, 1]

instead this is from webarkit-testing (WebARKitLib) :

matrixGL_RH: [-0.9817725823132032, 0.1899239396883738, -0.007175914667250705, 0, 0.02379396361358893, 0.16028175468996442, 0.9867844781962584, 0, 0.1885641639167419, 0.9686272018928405, -0.16187927550995185, 0, 0, 0, 0, 1]

note 12, 13, 14 index values are quite different, from webarkit-testing are all zeros... need to found where is the bug.

- new getGLViewMatrix function
@kalwalt
Copy link
Member Author

kalwalt commented Nov 18, 2023

Now i developed and implemented a new function getGLViewMatrix to pass the correct matrix, the sphere is displayed and don't move. To add to this: It's harder to detect and track (maybe because different video settings?) and even when the pinball pattern is not on the screen and for sure is not detected and tracked the application still output the message [info] Start Tracking!, i will open an issue to track it down. (this happens only for the threejs_ES6_example)

kalwalt added 2 commits March 7, 2024 19:50
- randomly imageData from the OffScreenCanvas is empty
@kalwalt
Copy link
Member Author

kalwalt commented Mar 7, 2024

I'm testing with the latest commits the speedy-vision library with my code. In detail: i'm using it to pass the data from the pinball marker and the video data to speedy-vision pipeline to convert to grey. It works fine but i have some issues updating the videoData. I will fix it soon.

@kalwalt
Copy link
Member Author

kalwalt commented Mar 8, 2024

Initially in various part i developed some update functions with requestAnimationFrame returning some data values, but that is not the best way doing this. it will not return correct values, better to provide a callback function or maybe a global variable that can be accessible outside of that function.

Now i changed my code with some callback functions but i always get ImageData with empty Uint8ClampedArray, why this? but maybe there is a smarter way to get this data with speedy vision?
after the call to pipeline.run() ( for the video data...) we got and ImageBitmap object and to retrieve raw data we need to process it with a canvas, but maybe there is a direct acces to an Uint8Array?

Investigating....

let dt = ctx.getImageData(0, 0, oWidth, oHeight);
data = ctx.getImageData(0, 0, oWidth, oHeight);

//console.log(data);
Copy link
Member Author

Choose a reason for hiding this comment

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

if you comment out this console.log it will ever return an ImageData with a correct (not empty) Uint8ClampedArray


requestAnimationFrame(update);
return dt;
Copy link
Member Author

Choose a reason for hiding this comment

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

a function with requestAnimationFrame should never return a value...

@kalwalt
Copy link
Member Author

kalwalt commented Mar 9, 2024

There are a lot of improves to do but probably the PnP code is ok, i will make a list here to take note:

  • The tracking is not stable, sometimes the sphere is bouncing off, sometimes is rendered very big other times very small...
  • If you move the pinball pattern image to the right, the sphere move in the opposite direction.
  • Sometimes the sphere is not rendered at all... but i think it depends if you open the dev console or not.

At least the issue i had with the persisting tracking is gone, but still a lot of works need to do.

@kalwalt
Copy link
Member Author

kalwalt commented Apr 1, 2024

I think this PR is quite long and all the code for the the PnP feature was implemented, there are other improvements to do but it's out of this scope. I will merge this soon.

@kalwalt kalwalt merged commit a155c76 into dev Apr 1, 2024
@kalwalt kalwalt deleted the improved-gtests branch June 6, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Emscripten / C / C++ all about Emscripten enhancement New feature or request Typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant