List
InstantPlaneGrid not getting far
Posted Date: 2018-01-19 10:48     Edited Date: 2018-01-23 14:44     Writer: inactive

Hello everybody,

we are using your amazing SDK (Unity) to develop a demo Android App, using IstantTracker mode.

First of all we draw, for every frame (in Update method), a small grid (modifying the InstantPlaneGrid found in your example), keeping finding/quiting surface, to let the user know where the object will be placed in the real world.

Everything works fine, but we have an issue related to the distance the grid is drawn.

If we point our phone back camera near our feet, let's say in horizontal position, everything is ok.

When we move the phone in vertical position, the grid is drawn fine until we reach more or less 60°, and then stop moving, so we cannot place the grid (and the object later on) "far" from our actual position.

Is there anyway to let the tracker keep on traking even to 70°/80° on the vertical position to reach our goal?

Thank you in advance.

Posted Date: 2018-01-22 6:11     Edited Date: 2018-01-22 6:11     Writer: kscho

Hello.

You're right. We currently limited an initial angle of instant tracker to approximately 60 to prevent a virtual object from appearing small. So, until an angle is near 60, a virtual grid is appear on the center of the screen and over 60, it is appear on the bottom of the screen, not the center.

To fit your purpose, we modified android sample source code (InstantTrackerActivity.java and InstantTrackerRenderer.java) and uploaded it into the link (https://github.com/maxstdev/InstantTrackerSample_ModifiedInitialPose). This code includes a converting method from an initial pose to your intended pose.

Please refer to onDrawFrame function of InstantTrackerRenderer.java.

Thanks.

 

- MAXST Support Team

Posted Date: 2018-01-22 10:51     Edited Date: 2018-01-22 10:51     Writer: inactive

Dear MAXST Team,

thank you very much for your great support!

We tried your code but unfortunately we couldn't make it work.

We probably expressed ourselves badly because we are not developing using Android Studio but Unity, we are just targeting Android as Unity player.

We naturally modified your code to C# and tried it in our InstantTracker script, but the plane grid disappeared.

Can you provide us the right code in C#? Maybe we did something wrong porting your example code.

Following you can find our code, that we placed in "Update()" method:

Matrix4x4 RT_t = trackable.GetPose();
float[] Tc = { RT_t[12], RT_t[13], RT_t[14] };
if (Tc[0] == 0.0f && Tc[1] == 0.0f && Tc[2] < Math.Sqrt(5.0))
{
    cvtMat = Matrix4x4.identity;
}
else
{
    float[] R0_t = { RT_t[0], RT_t[1], RT_t[2], RT_t[4], RT_t[5], RT_t[6], RT_t[8], RT_t[9], RT_t[10] };
    float dist = 1.0f / Math.Abs(RT_t[10]);
    float[] T0 = { 0, 0, dist };
    float[] Tt = { T0[0] - Tc[0], T0[1] - Tc[1], T0[2] - Tc[2] };
    float[] T1 = {R0_t[0]*Tt[0] + R0_t[1]*Tt[1] + R0_t[2]*Tt[2],
            R0_t[3]*Tt[0] + R0_t[4]*Tt[1] + R0_t[5]*Tt[2],
            R0_t[6]*Tt[0] + R0_t[7]*Tt[1] + R0_t[8]*Tt[2]};

    float[] RTn = { 1, 0, 0, T1[0], 0, 1, 0, T1[1], 0, 0, 1, T1[2], 0, 0, 0, 1 };
    cvtMat = new Matrix4x4();
    for (int i = 0; i < 16; i++)
    {
        cvtMat[i] = RTn[i];
    }
    cvtMat = cvtMat.transpose;
}

Matrix4x4 current = trackable.GetPose();
current = current * cvtMat;
Matrix4x4 poseMatrix = current * Matrix4x4.Translate(touchSumPosition);
instantTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), poseMatrix);

Thank you in advance.

Posted Date: 2018-01-23 5:40     Edited Date: 2018-01-23 5:40     Writer: kscho

Hello.

We uploaded unity source code into the same link (https://github.com/maxstdev/InstantTrackerSample_ModifiedInitialPose).

The reason why your code didn't work is a different coordinate system between Android and Unity.

 

- MAXST Support Team

Posted Date: 2018-01-23 14:44     Edited Date: 2018-01-23 14:44     Writer: inactive

Thank you very much, it works perfectly!