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

3D render #13

Open
rgm-22 opened this issue Sep 7, 2022 · 6 comments
Open

3D render #13

rgm-22 opened this issue Sep 7, 2022 · 6 comments

Comments

@rgm-22
Copy link

rgm-22 commented Sep 7, 2022

Hi @RivoLink!

Thank you very much for sharing this project.

Did you figure out how to properly make the 3D rendering?

I really appreciate any help you can provide :).

@RivoLink
Copy link
Owner

RivoLink commented Sep 8, 2022

Hi @rgm-22

I'm glad this project helped you.

I haven't been able to work on the 3d rendering yet but I have an augmented reality project that renders 3D objects perfectly on vuforia markers here : https://github.com/RivoLink/Vuforia-Android

Regards.

@rgm-22
Copy link
Author

rgm-22 commented Sep 8, 2022

Thank you very much for your answer, @RivoLink !

I have already checked out that project: pretty cool ;)

The thing is that I want to access the camera using OpenCV, which is not the case, isn't it?

Thank you again 👍

@RivoLink
Copy link
Owner

Hi @rgm-22

Yes, Vuforia-Adroid does not use OpenCV.

I will try to rework on this application and I will let you know if I manage to set up the 3D rendering.

Regards.

@rgm-22
Copy link
Author

rgm-22 commented Sep 12, 2022

Hi @RivoLink!

Thank you very much for your answer.

That would be great! :)

Sorry, I don't have any idea about 3D rendering and perhaps if you succeed placing a simple cube on an aruco origin, it would be very helpful to learn.

Thank you again!

@SoonBe
Copy link

SoonBe commented Sep 6, 2024

Is 3D rendering available now?
If it hasn't been implemented yet, I have something to share with you.
I understand that the 3D render issue (#13) was caused by the Object3D not appearing. If my understanding is correct, there's a simple way to make the Object3D visible.

(Step 1) Select a specific ID from ids of type MatOfInt
We will make Object3D appear only on a specific marker. Specify it as an integer variable
(e.g., private final int SELECT_MARKER_ID = 17;).
The reason for doing this part was because an error occurred because multiple IDs were recognized at once.

(Step 2) Add code to detect SELECT_MARKER_ID inside the for(int i = 0; i < ids.toArray().length; i++) statement in onCameraFrame method in MainActivity.java.
For example, I added this code:
if(ids.toArray()[i] == SELECT_MARKER_ID){
transformModel(tvecs.row(i), rvecs.row(i));
}

(Step 3) In transform method in Renderer3D.java,
remove this code:
if(!model.isVisible())
model.setVisible(true);

and make this part a separate method.
For example:
public void setModelVisibility(boolean visible) {
if (visible) {
model.setVisible(true);
} else {
model.setVisible(false);
}
}

(Step 4) Uncomment the transform code where it says /* Some bugs here. */.

(Step 5) Use the setModelVisibility method in MainActivity.java.
In onCameraFrame:
if (corners.size() > 0) {
.
.
.
} else if (corners.size() <= 0) {
renderer.setModelVisibility(false);
}

In transformModel:
public void run() {
renderer.setModelVisibility(true);

This way, I was able to see the cube appear when marker 17 was recognized.

@RivoLink
Copy link
Owner

RivoLink commented Sep 6, 2024

Hello @SoonBe

Thanks for your interest.

The main problem is not the rendering of the 3D model, it will work fine with your approach, but the problem is how to rotate/scale the 3D model to render it correctly above the marker.

For example, if the marker is tilted vertically, how to render the model with this tilt but still above the marker

Something like this Vuforia Android but with OpenCV

vuforia-android.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants