By daag123
on Sat, 02/23/2013 - 17:12
Hi,
I'm new to Vuforia SDK, I did many researches but I couldn’t find a proper answer. Is there a way to get the tracker (camera) rotation angles? I need to display several different images based on the tracker angle.For example: In 0 degrees one image and in 10 degrees another image and it goes on...For that I need to get the tracker rotation. Please acknowledge me on how to get the tracker angle, either from JAVA Android code or from C# code.It will be great if this can be achieved by Java Android code, But even C# code also would be fine. Thanks in advance.
Amal.
How to get Camera Rotation according to Tracker
Check out this KB article - https://developer.vuforia.com/resources/dev-guide/getting-camera-position
In Unity, you can accomplish the same using the camera transform.
How to get Camera Rotation according to Tracker
Thanks a lot for the guidance.
I checked the code for past few days and finally I managed to do it using
How to get Camera Rotation according to Tracker
The transform rotation.y is a Quaternion component. Try obtaining the rotation in Euler angles : http://docs.unity3d.com/Documentation/ScriptReference/Quaternion-eulerAngles.html
transform.rotation.eulerAngles : gives you the rotation in world space
How to get Camera Rotation according to Tracker
Thank you very much. I manage to get the proper angle now with degrees using
How to get Camera Rotation according to Tracker
To have the object follow the target, assign the target's transform as the transform.parent of the object.
http://docs.unity3d.com/Documentation/ScriptReference/Transform-parent.html
To have the object always look at the camera, use a lookAt method
How to get Camera Rotation according to Tracker
Thanks. Those are great ideas. I looked into the first idea which is, setting the object transform.parent to ImagerTarget transform. But then I came to notice that they do not provide any methods to retrieve the ImageTarget transform data. So I am going for the second option now.
How to get Camera Rotation according to Tracker
Here is how you can obtain the target's transform data ..
How to get Camera Rotation according to Tracker
Awesome !! Thanks a lot. Its working !! ;-)
This is the code line I was looking for
How to get Camera Rotation according to Tracker
Great - you're welcome.
How to get Camera Rotation according to Tracker
Hi again !!
When I was coding I came up with few more problems.
1) How to add a button on the screen display (not virtual buttons define in image targets) using C# code ? is it possible to do in C# script or do I have to jump to android code to add the button ?
How to get Camera Rotation according to Tracker
[quote=daag123]
Hi again !!
When I was coding I came up with few more problems.
How to get Camera Rotation according to Tracker
Hi,
Thanks a lot for the guidance. By following the information you gave I managed to save the camera image and put the button to GUI. Thanks again for that valuable information.
How to get Camera Rotation according to Tracker
I think this might be a question of how you are loading your projects. I'm only assuming you don't have much experience with Unity because you haven't used GUI's before but correct me if I'm wrong.
How to get Camera Rotation according to Tracker
Thanks a lot ! I manage to open the project according to your instructions. I am new to Unity3D. Forgive me for my poor experience on Unity3D. Now I'm practicing Unity3D and getting used to it functionalities. Highly appreciate your help.
Thanks.
How to get Camera Rotation according to Tracker
No problem. No judgements here. Just don't want to over/under explain things.
Glad you're making progress.
How to get Camera Rotation according to Tracker
Hi again,
For the past few days I'm trying to capture the camera image and save it in my device SD card. But still I cannot save the image.
How to get Camera Rotation according to Tracker
Did you try the code in this Knowledge Base article? - https://developer.vuforia.com/resources/dev-guide/unity-camera-image-access
How to get Camera Rotation according to Tracker
Hi,
Thanks a lot. I managed to do the code according to that artcle.
Appriciate your help.
Thank you.
I have few more questions.