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

Feature enhancement: PnP algorithm for pose Matrix calculation and other functions improves #23

Merged
merged 35 commits into from
Apr 1, 2024

Conversation

kalwalt
Copy link
Member

@kalwalt kalwalt commented Nov 2, 2023

From this issue #21 i'm trying to implement the PnP algorithm in our WebARKit project.

@kalwalt kalwalt added enhancement New feature or request C/C++ code concerning the C/C++ code design and improvements labels Nov 2, 2023
@kalwalt kalwalt self-assigned this Nov 2, 2023
@kalwalt
Copy link
Member Author

kalwalt commented Nov 2, 2023

I have this issue when the pinball image is tracked:

Uncaught RuntimeError: divide by zero
    at WebARKit::getPoseMatrix() (00d7f0c6:0x2be8cb)
    at emscripten::internal::MethodInvoker<emscripten::val (WebARKit::*)(), emscripten::val, WebARKit*>::invoke(emscripten::val (WebARKit::* const&)(), WebARKit*) (00d7f0c6:0x171b2a)
    at WebARKit.WebARKit$getPoseMatrix [as getPoseMatrix] (eval at EI (WebARKit.js:2:4774185), <anonymous>:8:10)
    at A.value (WebARKit.js:2:4803539)
    at A.value (WebARKit.js:2:4802767)
    at processFrame (worker.js:54:8)
    at self.onmessage (worker.js:16:7)
$WebARKit::getPoseMatrix() @ 00d7f0c6:0x2be8cb
$emscripten::internal::MethodInvoker<emscripten::val (WebARKit::*)(), emscripten::val, WebARKit*>::invoke(emscripten::val (WebARKit::* const&)(), WebARKit*) @ 00d7f0c6:0x171b2a
WebARKit$getPoseMatrix @ VM32:8
value @ WebARKit.js:2
value @ WebARKit.js:2
processFrame @ worker.js:54
self.onmessage @ worker.js:16

I dont't get why this happens but i think it's related on how the poseMatrix is passed out.
To be more specific: i think that this issue not come from the Typescript or javascript side, but it's in WASM code.

kalwalt added a commit to webarkit/webarkit-testing that referenced this pull request Nov 2, 2023
- m_camMatrix is filled correctly
- WebARKitTrackingInfo became a class:
- new invertPose, setScale, and getScale method for the scale of the pattern
- m_camMatrix as Matx33d
@kalwalt
Copy link
Member Author

kalwalt commented Nov 6, 2023

I was trying to make WebARKitGL file as only header, but i think it's better to continue with the convention as with other classes files(header and source in .cpp).

@kalwalt
Copy link
Member Author

kalwalt commented Nov 6, 2023

I have implemented the getCameraProjectionMatrix method so we have, in theory, all the "tools" to display a 3d mesh with our own 3d Engine now.

@kalwalt
Copy link
Member Author

kalwalt commented Nov 10, 2023

The action script fails with a seg fault probably because ubuntu need libjpeg or libopenjpeg installed.

@kalwalt
Copy link
Member Author

kalwalt commented Nov 10, 2023

The action script fails with a seg fault probably because ubuntu need libjpeg or libopenjpeg installed.

That is not right, otherwise it should fails also before.
The fact is: the image is 3 channels (RGB) but we expect 4 channels (RGBA), so the seg fault could be caused by this. The strange fact is this not happens on my local machine, and i'm testing with WSL and Ubuntu 22.04.
I will create a RGB ColorSpace and make required changes to WebARKitTracker class.

EDIT: There is already ColorSpace::RGB, no needs to add...

@kalwalt
Copy link
Member Author

kalwalt commented Nov 10, 2023

now the github action si passing regularly, i can add also support to RGB also for the processFrameData, even if i don't know if this will be ever used.

@kalwalt
Copy link
Member Author

kalwalt commented Nov 11, 2023

It would preferable, and this is appliable only to test for linux or Windows or other OS excluded Emscripten, to have an overloaded initTracker function with refData as a cv::Mat, maybe it could be useful also processFrameData, but we can start with the initTracker for now.
Moreover we have considered only RGB, RGBA or GRAYSCALE data, but data coming from imread i think are BGR. so we should consider also that options.

@kalwalt
Copy link
Member Author

kalwalt commented Mar 4, 2024

test failing because i have not updated the tests with the last changes, i will fix it.

@kalwalt
Copy link
Member Author

kalwalt commented Mar 4, 2024

test failing because i have not updated the tests with the last changes, i will fix it.

fixed with 63946b4

@kalwalt
Copy link
Member Author

kalwalt commented Mar 9, 2024

I think that the PnP code could be correct, i tested in the webarkit-testing repository in a browser with WASM. Maybe i could make a simple test in an desktop environment, testing on WASM i have some difficulties passing the data in the correct way, maybe with linux or Windows is simpler?

@kalwalt
Copy link
Member Author

kalwalt commented Apr 1, 2024

PnP code is implemented, merging it.

@kalwalt kalwalt merged commit 6e7e597 into dev Apr 1, 2024
1 check passed
@kalwalt kalwalt mentioned this pull request Apr 20, 2024
5 tasks
@kalwalt kalwalt deleted the feature-pnp branch June 6, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C/C++ code concerning the C/C++ code design and improvements enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant