Start a new topic

Find the bounding box of the recognized target

I'm using wikitude sdk version 5.2.0 for xamarin application, to detect the target image.

I'm successful in detecting the target, but struggling with getting the bounding box of the target image.

Is there any wikitude sdk api or plugin available to achieve the same.


Thanks.



Hi,



no, the JS SDK does not offer such an API. But since you know exactly which target you just recognized by name, you can just hard-code the aspect ratio for each target. No need for an API.


if (target.name === "myTarget1") {

    var aspect = 4.0/3.0;

    ...

} else if (target.name === "myTarget2") {

    var aspect = 16.0/9.0;

    ...

}


As for the native sample, you can just download the native SDK package of your choice. They all contain a comprehensive sample applications. The first image tracking sample demonstrates what you are looking for.



- Daniel



1 person likes this

Hi Daniel,


Thank you for the quick response.

I will try native sdk package and check whether it will be able to solve my problem.


Thanks

Harjot Kaur


Hi Daniel,


Is there is any other possible way to find the properties of recognized target image in xamarin android, similar to what it is done using android native sdk.

Hi,



as I believe I've said before, there is not. The JS SDKs are designed for ease of use and to cover conventional use cases. If you need full control, native is the way to go.



- Daniel

Hi,



with our JavaScript based SDKs, there is no way for you to access this information, you would have to use the native SDK. May I ask what you would be doing with the bounding box? What's your exact use case? Maybe there's another way of achieving it.



- Daniel

Hi,

Thanks for replying to my query.

I need to find the properties of the target image being recognized, like its position in the scene, its height and width, so that we can highlight its features accurately. I was trying to achieve this overlaying its with a bounding box of same height and width, but in was not successful in doing so using xamarin javascript based sdk.

Is it possible using existing sdk or we need to use native sdk or any other way of achieving this?


Thanks

Harjot


Good morning,



if you need to actually read these values, you'll need to use the native SDK. The JavaScript SDKs do, however, allow you to render augmentations that match target images exactly, like bounding boxes.


When targets are tracked, the coordinate system is set up such that 1 corresponds to the height of the target. The width you can work out by applying the aspect ratio of your target. So, if you don't apply any transformations and have an augmentation that has the same aspect ratio as your physical image target, you will have an augmentation that matches your target perfectly. Is this what you want to achieve?


Here's the corresponding documentation: https://www.wikitude.com/external/doc/documentation/latest/Reference/JavaScript%20API/modules/AR.html



- Daniel

Hi Daniel,

On target detection, is there any way of getting the aspect ratio of target image?

If yes, then can we scale the overlay image on basis of that aspect ratio?


Regarding the native sdk, it would be a lot of help, if can you share a sample code or documentation for the same.


Thanks

Harjot Kaur





Login or Signup to post a comment