Log in or register to post comments

Getting camera pose in Unity

April 29, 2013 - 11:40pm #1

I'm trying to get the camera pose based on each marker like in this post:

https://developer.vuforia.com/resources/dev-guide/getting-camera-position

I'm using Unity 3, and don't know how much of the Vuforia API I can reference. All I really need is to be able to do

trackable->GetPose()

and I can find or write matrix libraries that invert the 3x4 matrix and extract the camera position relative to the trackable. How do I access the regular API from Unity?

Getting camera pose in Unity

April 30, 2013 - 8:53am #4

However, isn't gameObject.transform the transform between the world coordinates and the gameObject?

Correct. But that's your starting point. Then you need to get the Camera matrices as well and then you can combine the transform matrices together so to go from object to camera coordinates. That's part of the Unity API (see also the Camera API), it's not something specific to Vuforia.

 

Getting camera pose in Unity

April 30, 2013 - 1:00am #3

Thank you, that is helpful. However, isn't gameObject.transform the transform between the world coordinates and the gameObject? I'm specifically looking for the camera position based on the individual tracker pose. I'm using FrameMarkers, and would like to get a camera position for each one. My linear algebra is a little rusty, but don't I need the camera perspective matrix and the gameObject to world coordinate transform? It starts getting a bit more complex after that. 

Getting camera pose in Unity

April 29, 2013 - 11:59pm #2

Hi, the article you are referring to is only applicable in native code (Android or iOS), but not in Unity.

In Unity things are much easier, as you can get the Trackable pose directly from the transform of your trackable object.

For instance, if you attach a script to one of your ImageTarget, you can just retrieve its transformation using:

this.gameObject.transform;

(this.transform should also work)

Then, once you have that, you can manipulate it in the way you want, using the Unity API (not the Vuforia API).

See:

http://docs.unity3d.com/Documentation/ScriptReference/Transform.html

http://docs.unity3d.com/Documentation/ScriptReference/Matrix4x4.html

 

 

Log in or register to post comments