Log in or register to post comments

Filter Camera Position and Rotation to avoid jitter?

March 9, 2017 - 9:28am #20

Brujo2012 wrote:

Hi:

I updated the code to the last vuforia version (working on Feb 2017), including the math script in this package, so you only need attach the smooth script to de ARCamera.

 

Saluts

 

Hi,

sorry but this package is it is empty, we try import to unity but not import nothing. If you to be so kind, please, you can update it.

Thank you very much.

 

Regards,

Jorge.

Filter Camera Position and Rotation to avoid jitter?

April 14, 2017 - 7:32pm #19

Hi Jorge.

You only need drag 2 files to your project (SmoothCamera.cs and Math.cs with necessary functions), then drag to Vuforia ARCamera, set your desired amount of frames to apply the effect, and go!

I hope it helps you

AttachmentSize
Package icon ForSmooth-CompressedFiles.zip8.26 KB

Filter Camera Position and Rotation to avoid jitter?

August 3, 2017 - 2:40am #18

Could not get ForSmooth to work ...

Unity 5.6.3

Vuforia 6.0

Assets/EmptyClass.cs(11,30): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing `UnityEngine' using directive?

Any ideas for a noob?:)

Filter Camera Position and Rotation to avoid jitter?

August 3, 2017 - 12:10pm #17

Make sure you include "using UnityEngine;" at the top of your file.

Thanks,

-Vuforia Support

Filter Camera Position and Rotation to avoid jitter?

August 4, 2017 - 4:06pm #16

Thanks for the prompt reply.

I get this error;

Assets/SmoothCamera.cs(52,3): error CS0246: The type or namespace name `VuforiaARController' could not be found. Are you missing an assembly reference?

Image of MonoDevelop attached.

This configuration required to run video file on Android;

Unity 5.6.3

Vuforia 6.0

AttachmentSize
Image icon camera-smooth-error.jpeg240.39 KB

Filter Camera Position and Rotation to avoid jitter?

November 1, 2017 - 5:30pm #15

Has anyone get this to work? My 3d object still jitter and shakes when I move backwards with the target in my view.

Filter Camera Position and Rotation to avoid jitter?

January 3, 2018 - 6:23am #14

For me ForSmooth package works very good.

But I have one problem. It is when I am using more scenes. If I switch in play mode from one scene where is ARCamera with SmoothCamera script on it to other scene, where is ARCamera with SmoothCamera script on it, I get following Exception:

Exception in callback: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> UnityEngine.MissingReferenceException: The object of type 'SmoothCamera' has been destroyed but you are still trying to access it.

Your script should either check if it is null or you should not destroy the object.

  at (wrapper managed-to-native) UnityEngine.Component:get_transform ()

  at SmoothCamera.OnTrackablesUpdated () [0x00038] in C:\Users\admin\Documents\Unity\CCBAR2017\Assets\Source\SmoothCamera.cs:33

  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)

  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000d0] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222

  --- End of inner exception stack trace ---

  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000eb] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232

  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115

  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000b9] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:443

  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00018] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MulticastDelegate.cs:71

  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:415

  at Vuforia.DelegateHelper.InvokeDelegate (System.Delegate action, System.Object[] args) [0x00000] in <filename unknown>:0

UnityEngine.Debug:LogError(Object)

Vuforia.DelegateHelper:InvokeDelegate(Delegate, Object[])

Vuforia.DelegateHelper:InvokeWithExceptionHandling(Action)

Vuforia.VuforiaARController:UpdateStatePrivate(Boolean, Boolean)

Vuforia.VuforiaARController:UpdateState(Boolean, Boolean)

Vuforia.DigitalEyewearARController:Update()

System.Delegate:DynamicInvoke(Object[])

Vuforia.DelegateHelper:InvokeDelegate(Delegate, Object[])

Vuforia.DelegateHelper:InvokeWithExceptionHandling(Action)

Vuforia.VuforiaBehaviour:Update()

 

In a few seconds I get this exception (red labeled) in Unity 999+ times.

Can someone help me with this problem?

Filter Camera Position and Rotation to avoid jitter?

May 2, 2018 - 7:14am #13

I have folloed the solution provided by "KoyoDevelopment" at the Timestamp "March 21, 2015 - 11:16pm".I simply dragged those code files into assets from Unity Editor,but no use.I simply cannot attach the code in smoothcamera.CS to ARCamera, becuase Vuforia.QCARBehaviour is also not recognizable and It still is not compiling nicely.



*ERROR is Assets/SmoothCamera.cs(10,21): error CS0234: The type or namespace name `QCARBehaviour' does not exist in the namespace `Vuforia'. Are you missing an assembly reference?

 

Unity version is 5.4.3f1

Vuforia version is 6-1-17

 

Can I get a Clue to correct that Smiple bug?

Filter Camera Position and Rotation to avoid jitter?

July 25, 2018 - 12:34am #12

Facing the same issue in vuforia version 7.2.I applied both script on my ar camera as suggested and  10(Smooth Frames) Now Jittering thing is fixed but floating thing is started.All images are of 4 and 5 Star also have good lightning condition.I set World Centre Mode to First_Target. Thanks in advance.Sorry for bad English.

 

Filter Camera Position and Rotation to avoid jitter?

July 25, 2018 - 2:28am #11

hi  nicks2580 I am also facing similar issue .Did you find any solution?

Filter Camera Position and Rotation to avoid jitter?

July 26, 2018 - 4:49am #10

hi brujo.I added your script to the ar camera .the jitter almost solved but my augmentations  getting jumpy smoothly.Is there any workaround.

Filter Camera Position and Rotation to avoid jitter?

July 31, 2018 - 12:55am #9

Hi!! did you find a solution for the same

 

Filter Camera Position and Rotation to avoid jitter?

March 18, 2019 - 4:13am #8

Hi Brujo2012, currently in unity 2018 version 3.3f1 and vuforia version 8.0.10 the script does not work, it has errors, I have tried to solve it but I do not understand some things, if you could guide me and I solve the problem to update the script, I leave you images of the errors that it presents unity. Thanks

 

Filter Camera Position and Rotation to avoid jitter?

June 13, 2019 - 8:37am #7

Hey Julio,

I am using Vuforia version 8.1.10 and had to do a little updating to the code in order to get it to work.

Below is the currently working code when used alongside the Math3D script mentioned in other comments. So as not to replace the original I renamed it to Math3DJitterFix which is why it is named as such below but other than that this should be copy paste ready. Hope this helps!

using UnityEngine;

using System.Collections;

using System.Collections.Generic;

using Vuforia;

[RequireComponent(typeof (VuforiaBehaviour))]

public class SmoothCamera : MonoBehaviour

{

    public int smoothingFrames = 10;

    private VuforiaBehaviour qcarBehavior;

    private Quaternion smoothedRotation;

    private Vector3 smoothedPosition;

    private Queue<Quaternion> rotations;

    private Queue<Vector3> positions;

    public void OnInitialized()

    {

    }

    public void OnTrackablesUpdated()

    {

        if (rotations.Count >= smoothingFrames)

        {

            rotations.Dequeue();

            positions.Dequeue();

        }

       

        rotations.Enqueue(transform.rotation);

        positions.Enqueue(transform.position);

        Vector4 avgr = Vector4.zero;

        foreach (Quaternion singleRotation in rotations)

        {

            Math3dJitterFix.AverageQuaternion(ref avgr, singleRotation, rotations.Peek(), rotations.Count);

        }

        Vector3 avgp = Vector3.zero;

        foreach (Vector3 singlePosition in positions)

        {

            avgp += singlePosition;

        }

        avgp /= positions.Count;

        smoothedRotation = new Quaternion(avgr.x, avgr.y, avgr.z, avgr.w);

        smoothedPosition = avgp;

    }

    // Use this for initialization

    void Start ()

    {

        rotations = new Queue<Quaternion>(smoothingFrames);

        positions = new Queue<Vector3>(smoothingFrames);

        qcarBehavior = GetComponent<VuforiaBehaviour>();

        VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnInitialized);

        VuforiaARController.Instance.RegisterTrackablesUpdatedCallback(OnTrackablesUpdated);

    }



    // Update is called once per frame

    void LateUpdate ()

    {

        transform.rotation = smoothedRotation;

        transform.position = smoothedPosition;

    }

}

Filter Camera Position and Rotation to avoid jitter?

June 29, 2019 - 1:04pm #6

Thank you...

Filter Camera Position and Rotation to avoid jitter?

July 29, 2019 - 4:13pm #5

HI

I resolve the "The object of type 'Smooth Camera' has been destroyed but you are still trying to access it." issue with a boolean to stop the function in the OnTrackablesUpdated, like this:

public bool Tracking = true;

    public void corte(){

        Tracking = false;

      

    }

 

public void OnTrackablesUpdated()

    {

        if (Tracking == true)

        {

            if (rotations.Count >= smoothingFrames)

        {

            rotations.Dequeue();

            positions.Dequeue();

        }

....

Filter Camera Position and Rotation to avoid jitter?

August 22, 2019 - 9:29am #4

Put this code to ARCamera

Add Math3d.cs

 

using UnityEngine;

using System.Collections.Generic;

using Vuforia;

[RequireComponent(typeof(VuforiaBehaviour))]

public class SmoothCamera : MonoBehaviour

{

    public int smoothingFrames = 10;

    private VuforiaBehaviour qcarBehavior;

    private Quaternion smoothedRotation;

    private Vector3 smoothedPosition;

    private Queue<Quaternion> rotations;

    private Queue<Vector3> positions;

    public void OnInitialized()

    {

    }

    public void OnTrackablesUpdated()

    {

        if (rotations.Count >= smoothingFrames)

        {

            rotations.Dequeue();

            positions.Dequeue();

        }

        rotations.Enqueue(transform.rotation);

        positions.Enqueue(transform.position);

        Vector4 avgr = Vector4.zero;

        foreach (Quaternion singleRotation in rotations)

        {

            Math3d.AverageQuaternion(ref avgr, singleRotation, rotations.Peek(), rotations.Count);

        }

        Vector3 avgp = Vector3.zero;

        foreach (Vector3 singlePosition in positions)

        {

            avgp += singlePosition;

        }

        avgp /= positions.Count;

        smoothedRotation = new Quaternion(avgr.x, avgr.y, avgr.z, avgr.w);

        smoothedPosition = avgp;

    }

    // Use this for initialization

    void Start()

    {

        rotations = new Queue<Quaternion>(smoothingFrames);

        positions = new Queue<Vector3>(smoothingFrames);

        //qcarBehavior = GetComponent<VuforiaARController>();

       

        VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnInitialized);

        VuforiaARController.Instance.RegisterTrackablesUpdatedCallback(OnTrackablesUpdated);

    }

    // Update is called once per frame

    void LateUpdate()

    {

        transform.rotation = smoothedRotation;

        transform.position = smoothedPosition;

    }

}

 

Filter Camera Position and Rotation to avoid jitter?

September 10, 2019 - 2:30am #3

Hi I tried this and It only works on my Editor, but when i deploy it on Android device, nothing happens. I'm currently using Unity 2019.2.2f1 with Vuforia 8.3.8. I hope someone could help me. Thanks.

Filter Camera Position and Rotation to avoid jitter?

September 28, 2019 - 7:56am #2

hello kikesa72

i tried your solution about  ( "The object of type 'Smooth Camera' has been destroyed )but the problem still present .

the script work good but when load another scene with ar camera the error appears .

can you help ?

Filter Camera Position and Rotation to avoid jitter?

October 29, 2019 - 6:40am #1

If I use Math3d.cs and SmoothCamera.cs, will it make a difference what the World Center Mode is? What about enabling Extended Tracking? Using Vuforia 8.5

Pages

Log in or register to post comments