Why does EasyAR frequently lose tracking?

0 votes
asked Jan 15, 2019 by jstrout (120 points)
I'm evaluating EasyAR for our needs, using the sample Unity apps.  All we need is to track a single target, but we need to do that reliably, anywhere in the camera's field of view.

But what I find is, EasyAR frequently loses the target, even when it is still clearly in view, and not moving too fast.  Then if I wait long enough or shift it slightly, it finds it again.  I tried both with the targets included with the samples, as well as a simple QR code.

Is that the best we can do?  Or are there some tricks to getting it to more reliably see a target in the camera feed?

2 Answers

0 votes
answered Jan 15, 2019 by zhnagjian (11,130 points)

Based on the information you provide: EasyAR frequently loses the target, even when it is still clearly in view, and not moving too fast.  Then if I wait long enough or shift it slightly, it finds it again. 

First of all, your recognition target must satisfy the rich texture and the material cannot be reflective or obscured by transparent objects. If this problem still occurs, you can send the target and the video with the problem to  zhangjian@sightp.com

0 votes
answered Jan 16, 2019 by nikhilsinghpundir (270 points)
edited Jan 16, 2019 by nikhilsinghpundir
If someone is using Image targets then try these steps

Create the image as grayscale and the greatest side of the image as 1920px.  Use jpg over png. I have got the best results with images of size 400kb or less.

Along with this, I have overridden the Ontrackinglost function. Now whenever tracking is lost the script waits for 0.25f and after the delay all the renderers of the child objects are disabled. If the object is found again during the delay then OnTrackingFound function cancels all the invokes.

You can use this function in imagetargetbehaviour to reduce flickering of child objects

 private float lastX;
        private float lastRX;
        private float lastY;
        private float lastRY;
        private float lastZ;
        private float lastRZ;

        // Fine-tune this values according to your own project
        public float rotMin = 3f;
        public float rotMax = 12f;
        public float trasMin = 0.06f;
        public float trasMax = 2;
        public float lerpT = 0.2f;

  protected override void Update()
        {
            base.Update();

            float myrx = 0;
            myrx = this.transform.localEulerAngles.x;
            while (myrx >= 360)
            {
                myrx -= 360;
            }
            while (myrx <= -360)
            {
                myrx += 360;
            }
            while (myrx > 270 && 360 - myrx >= 0)
                myrx = -(360 - myrx);
            float myry = 0;
            myry = this.transform.localEulerAngles.y;
            while (myry >= 360)
            {
                myry -= 360;
            }
            while (myry <= -360)
            {
                myry += 360;
            }

            while (myry > 270 && 360 - myry >= 0)
                myry = -(360 - myry);

            float myrz = 0;
            myrz = this.transform.localEulerAngles.z;
            while (myrz >= 360)
            {
                myrz -= 360;
            }

            while (myrz <= -360)
            {
                myrz += 360;
            }

            while (myrz > 270 && 360 - myrz >= 0)
                myrz = -(360 - myrz);

            if (
                (
                    (Mathf.Abs(this.transform.position.x - lastX) > trasMin || Mathf.Abs(this.transform.position.y - lastY) > trasMin || Mathf.Abs(this.transform.position.z - lastZ) > trasMin) &&
                    (Mathf.Abs(this.transform.position.x - lastX) < trasMax || Mathf.Abs(this.transform.position.y - lastY) < trasMax || Mathf.Abs(this.transform.position.z - lastZ) < trasMax)) ||
                (
                    (Mathf.Abs(myrx - lastRX) > rotMin && Mathf.Abs(myry - lastRY) > rotMin && Mathf.Abs(myrz - lastRZ) > rotMin) &&
                    (Mathf.Abs(myrx - lastRX) < rotMax || Mathf.Abs(myry - lastRY) < rotMax || Mathf.Abs(myrz - lastRZ) < rotMax)
                )
            )
            {
                lastX = Mathf.Lerp(lastX, this.transform.position.x, lerpT);
                lastY = Mathf.Lerp(lastY, this.transform.position.y, lerpT);
                lastZ = Mathf.Lerp(lastZ, this.transform.position.z, lerpT);
                lastRX = Mathf.Lerp(lastRX, myrx, lerpT);
                lastRY = Mathf.Lerp(lastRY, myry, lerpT);
                lastRZ = Mathf.Lerp(lastRZ, myrz, lerpT);
            }
            else
            {
                this.transform.rotation = Quaternion.Euler(lastRX, lastRY, lastRZ);
                this.transform.position = new Vector3(lastX, lastY, lastZ);

            }
        }

Hope this helps,
Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...