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

How I can pull rotation matrix ? #237

Closed
holaworlds opened this issue Aug 9, 2021 · 7 comments
Closed

How I can pull rotation matrix ? #237

holaworlds opened this issue Aug 9, 2021 · 7 comments
Labels
solution:objectron Issue about Objectron type:feature New feature or request

Comments

@holaworlds
Copy link

Hi,

I checked ObjectDetection3dGraph, OfficialDemoGraph, DemoGraph but can not see the way I can pull rotation matrix and use it. Or another question, where did 3D BB renderer got called in these classes?

thanks for your help!

@DrQwertySilence
Copy link

DrQwertySilence commented Aug 9, 2021

Edit: I'm assuming you are speaking about the "facemesh" like solutions, true?

From what I know you need to calculate it (I don't know if this Package has some utility for that). What I do is:

  1. Get some vertices that are somewhat stable (the one that form the "face oval" excluding the jaw and the forehead are good)
  2. Calculate the centroid of the previous vertices.
  3. Get a stable reference point in the front of the face (the ones from the nose are pretty good) and form a vector with the previous vertex (try to make it parallel to unity's Z axis so you don't have to adjust it latter).

With that vector you should be able to do what you want.

@holaworlds
Copy link
Author

Hi DrQwertySilence, thank you for explanation, I'm using shoe example. I want to render my own shoe game object using detected 3D Bounding Box. Which scripts are u using to manipulate/pull rotation/translation data ?

@DrQwertySilence
Copy link

If you know the box vertices (8 vertices) you should be able to use Unity's Quaternion.LookRotation(Vector3 forward, Vector3 up) function.
box_edges
Pick those two edges and pass them to the previous function.

@holaworlds
Copy link
Author

I was hoping that these 3 rotations (x,y,z) calculated somewhere in the project already and I can use it to render and rotate my objects. Do you know by chance how can I do this?

@ROBYER1
Copy link

ROBYER1 commented Dec 1, 2021

I saw that there was the addition of RotationAngle in the HolisticLandmarkListAnnotation.cs and also in a HierarchicalAnnotation.cs script but couldn't find an example in pose or holistic samples that reads these rotation angle values

@emirhanylmzz
Copy link

@holaworlds @ROBYER1 Did you get any solutions ?

@homuler homuler added type:feature New feature or request solution:objectron Issue about Objectron labels Jan 10, 2022
@homuler
Copy link
Owner

homuler commented May 20, 2022

CameraCoordinate.GetApproximateQuaternion can be used to get a Quaternion.

public static Quaternion GetApproximateQuaternion(ObjectAnnotation objectAnnotation, RotationAngle imageRotation = RotationAngle.Rotation0, bool isMirrored = false)
{
var isInverted = IsInverted(imageRotation);
var isXReversed = IsXReversed(imageRotation, isMirrored);
var isYReversed = IsYReversed(imageRotation, isMirrored);
var forward = GetZDir(objectAnnotation, isXReversed, isYReversed, isInverted);
var upward = GetYDir(objectAnnotation, isXReversed, isYReversed, isInverted);
return Quaternion.LookRotation(forward, upward);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution:objectron Issue about Objectron type:feature New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants