Topic locked

image target width and height

March 19, 2014 - 6:25am #1

Hello!

Is there a way to get trackable image width and height, both for images on Cloud DB without using metadata? I am using SDK 2.8.7 and Unity 4.2.1f (C#).

The command to retrieve target image size is,

float imageWidth = targetSearchResult.TargetSize;

But this only gives width and not height.

Thanks in advance!

image target width and height

March 24, 2014 - 5:47am #6

You're welcome.

image target width and height

March 24, 2014 - 5:26am #5

Hi!

Oh...yes. Why didn't I think about this..? I have sorted it out now.

Thanks a lot for your help Alessandro!

image target width and height

March 24, 2014 - 1:19am #4

Hi, from what I see, the reason seems to be simple:

the first time you query the size, the target has not yet been detected, so the trackable is probably taken from the template target that you have in your Scene, which has probably a predefined size of 200. Then, once the target are actually detected from the cloud, the size is correctly updated to reflect the actual target size.

 

image target width and height

March 24, 2014 - 1:06am #3
Thanks for the reply Alessandro!
 
I tried fetching cloud DB image dimensions using GetSize() method in OnTrackingFound() method,
Vector2 trackedCloudImageWH = GameObject.Find ("CloudRecoTarget").GetComponent<ImageTargetAbstractBehaviour>().GetSize();

This gives the image width and height, but when I start the project in Play mode in Unity3D, on tracking any image from cloud DB for the first time I get 2 results, first (200.0, 200.0) and second is the real width and height. If I continue to track other images then I don't get (200.0, 200.0) for rest of the images. Please refer the screenshot for debug log.

 
I couldn't find the reason for this behaviour. Am I missing something? How do I stop Unity from throwing (200.0, 200.0) output for image dimensions?
 
Thanks in advance!

image target width and height

March 19, 2014 - 8:18am #2

You can get the actual 2D size (width and height) from the ImageTarget class, using the GetSize() method, see:

https://developer.vuforia.com/resources/api/unity/interface_image_target

Note: this will not be reported in the TargetSearchResult, but it will be part of the ImageTarget that is created at runtime from your TargetSearchResult.

 

 

Topic locked