Search code examples
c#unity-game-enginevuforia

How to set an image target so that it detects all sizes of the same image target


What I am trying to do is augment a video on the appearance of a logo.

But my doubt is, what if this logo appears in different sizes in different places?

Can vuforia detect these size differences and still augment the video?

I want to be able to do this


Solution

  • Short answer: You can't.

    Vuforia needs to know the actual real world size of the target in order to place your virtual 3D objects to the correct position especially regarding the depth.

    It brakes (simply returns incorrect depth positions) if the sizes don't match. E.g. if your real target is smaller then what you configured in Unity then your virtual content will allways be placed "too far away" since Vuforia expects your real target to be bigger.

    You can not differ in any way between different scaled but equal image targets .. none of the tracking software I know is capable of that since it usually is used for actually placing 3D content to 3D world positions .. this would simply be impossible if you don't have a fixed expected target size since if you move closer the target is gets bigger for the camera.

    If there are multiple targets with the same image visible to Vuforia at the same time it will only take the first one it found.

    Vuforia offers a way to change the expected target size at runtime see Targets for more information, however this won't work in your case for automatically detect the correct size.

    See [ImageTargets]

    TargetSize

    • Actual size of the image target in 3D scene units.
    • Developer must specify the target size when creating the target online or in the Database Configuration XML file. The Database Configuration XML file is generated by the Target Manager, but once created, it can be modified by the developer.
    • The target size parameter is important, since the pose information returned during tracking will be in the same scale. For example, if the target image is 16 units wide, then moving the camera from the left border of the target to the right border of the target changes the returned position by 16 units along the x-axis.
      • (x, y) - Target size in scene units measured along the horizontal and vertical axes of the rectangular target.

    Note: The size of the image target can be changed at runtime. This offers flexibility in defining or updating the scale of the target in your 3D scene.

    Note: Developers looking to use image targets in combination with Positional Device Tracker should specify the target size in meters


    On the other hand if you only care about a pure bool value "Is the target found at all or not" for enabling and disabling somthing without caring about the 3D position and only in this case then yes you can use it but you won't get any information about which of the different sizes was found or not or how far it is actually away from the camera or any useful 3D position.

    You might be able to fix that on modern AR headsets using Spacial mapping since the x/y position still should be correct only not the depth z position (axis in camera space)