AR Object jitter in Unity (iOS)

+2 votes
asked Aug 14, 2017 by rluppino (220 points) 1 flag
I have used the HelloAR Unity sample and built up my project and everything is working except that the 3D AR object jitters a lot after the marker is detected.

I've been informed that I need to create a second AR camera to render the target only but I'm not sure how to do this. The HelloAR sample already has 2 cameras.

Any help is greatly appreciated. This is super urgent and I need to get this stable ASAP.

Thanks.

2 Answers

0 votes
answered Aug 14, 2017 by rluppino (220 points)
edited Aug 14, 2017 by rluppino
EDIT: Sorry, this is not the answer, just a follow up comment. Problem still unresolved.

I have created the 2nd camera and moved my objects to different layers but the jitter is still there. This is what I did.

1) Moved my 3D object (the one rendered after the marker is detected) into a new layer called Model

2) Copied the ARCamera object to create a second camera and set it culling mask to only render the Model layer. I modified the culling mask of the original camera to exclude the Model layer. This new camera is also in the Model layer (if I keep it in the default layer, I don't see the reality plane i.e. device camera when I run my app).

So my model is rendered as it was when I only had 1 camera but the jitter is still there even though the model itself is being rendered by a different camera to the image target.

Is there something I've done wrong? When looking at the view of the camera that is detecting the target, where should the marker image be in relation to the view bounds? i.e. should it take up the whole view (as much as possible) or should it be small and centre?

Any further guidance is greatly appreciated.

Thanks
commented Aug 14, 2017 by albert52 (31,850 points)
maybe you can try(you need to set the appropriate value。):

1.change the EasyImageTargetBehaviour.cs  Update(),  you can see.

    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 (((Math.Abs(this.transform.position.x - lastX) > 0.06 || Math.Abs(this.transform.position.y - lastY) > 0.06 || Math.Abs(this.transform.position.z - lastZ) > 0.06)&&
            (Math.Abs(this.transform.position.x - lastX) > 0.13 || Math.Abs(this.transform.position.y - lastY) > 0.13 || Math.Abs(this.transform.position.z - lastZ) > 0.13))||
            ( (Math.Abs(myrx - lastRX) > 3 &&Math.Abs(myry - lastRY) >3 &&Math.Abs(myrz - lastRZ) > 3)&& (Math.Abs(myrx - lastRX) > 6 || Math.Abs(myry - lastRY) > 6 || Math.Abs(myrz - lastRZ) > 6))
                {
                    lastX = this.transform.position.x;
                    lastY = this.transform.position.y;
                    lastZ = this.transform.position.z;
                    lastRX = myrx;
                    lastRY = myry;
                    lastRZ = myrz;
                this.transform.rotation = Quaternion.Euler(lastRX, lastRY, lastRZ);
                this.transform.position = new Vector3(lastX, lastY, lastZ);
                }
                else
                {
             
                    this.transform.rotation = Quaternion.Euler(lastRX, lastRY, lastRZ);
                    this.transform.position = new Vector3(lastX, lastY, lastZ);
                }
           
        }
commented Aug 14, 2017 by rluppino (220 points)
Thank you for your suggestion but it doesn't seem to reduce the jitter at all. The x, y and z values  of localEulerAngles are always zero as are the x,y,z of the object's position and rotation. That seems very strange to me right? IS this a clue that something else is going on?
commented Aug 14, 2017 by rluppino (220 points)
The other thing I have noticed is that the jitter is worse when I am looking at the image target from directly in front. If I tilt my phone to the right, the jitter is not nearly as bad (but still slightly there).
0 votes
answered Aug 16, 2017 by sanket (300 points)

Please check the quality of marker :

The more balanced the distribution of the rich features in the image, the better the image can be detected and tracked and 3D object is stable in proportion.

Set camera frame rate to SupportedFPS. 

ref. 

  • float CameraFPS 
  • float[] SupportedFPS

Also try to reduce frame rate as possible as

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