Log in or register to post comments

Filter Camera Position and Rotation to avoid jitter?

April 9, 2012 - 11:43am #1

Can i do that?

I'm trying to figure where is the camera transform updated, but i can't find it.

Can i filter those values so i can avoid some jitter in the camera? Basically, smooth the movement of the camera, something like a low pass filter, because it jitters too much and is very noticeable.

Cheers.

Filter Camera Position and Rotation to avoid jitter?

September 28, 2019 - 7:56am #120

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?

September 10, 2019 - 2:30am #119

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?

August 22, 2019 - 9:29am #118

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?

July 29, 2019 - 4:13pm #117

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?

June 29, 2019 - 1:04pm #116

Thank you...

Filter Camera Position and Rotation to avoid jitter?

June 13, 2019 - 8:37am #115

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?

March 18, 2019 - 4:13am #114

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?

July 31, 2018 - 12:55am #113

Hi!! did you find a solution for the same

 

Filter Camera Position and Rotation to avoid jitter?

July 26, 2018 - 4:49am #112

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 25, 2018 - 2:28am #111

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

Filter Camera Position and Rotation to avoid jitter?

July 25, 2018 - 12:34am #110

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?

May 2, 2018 - 7:14am #109

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?

January 3, 2018 - 6:23am #108

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?

November 1, 2017 - 5:30pm #107

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?

August 4, 2017 - 4:06pm #106

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?

August 3, 2017 - 12:10pm #105

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

Thanks,

-Vuforia Support

Filter Camera Position and Rotation to avoid jitter?

August 3, 2017 - 2:40am #104

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?

April 14, 2017 - 7:32pm #103

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?

March 9, 2017 - 9:28am #102

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?

March 9, 2017 - 9:26am #101

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?

February 17, 2017 - 11:02pm #100

what does this mean? i just imported it to my project. 

Assets/Scripts/Vuforia-Smooth-Script/SmoothCamera.cs(52,17): error CS0246: The type or namespace name `VuforiaARController' could not be found. Are you missing a using directive or an assembly reference?. sorry for the noob question. im just new in ar. thankyouu 

Filter Camera Position and Rotation to avoid jitter?

February 2, 2017 - 5:53am #99

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

Filter Camera Position and Rotation to avoid jitter?

January 29, 2017 - 4:26am #98

I also had this issue. After reading docs i got this to work.

public class DataSetConfig : MonoBehaviour,ITrackerEventHandler {

	
	// Use this for initialization
	void Start () {
		
		Vuforia.VuforiaARController.Instance.RegisterTrackablesUpdatedCallback(OnTrackablesUpdated);
		Vuforia.VuforiaARController.Instance.RegisterVuforiaStartedCallback (OnInitialized);
	}

	// Update is called once per frame
	void Update () {
		
	}

	#region ITrackerEventHandler implementation

	public void OnInitialized ()
	{
		//throw new System.NotImplementedException ();
		Debug.Log("Trackers initialized");
	
	}

	public void OnTrackablesUpdated ()
	{
		//throw new System.NotImplementedException ();
		Debug.Log("Trackers Updated");
	}

	#endregion
}

 

 

 

 

 

 

 

 

 

 

 

 

Filter Camera Position and Rotation to avoid jitter?

January 24, 2017 - 11:03am #97

For me it was working fine for iphone and android after using the script. But with ipad screen again jitters

Anybody has a solution to that

Filter Camera Position and Rotation to avoid jitter?

January 17, 2017 - 1:05am #96

Hi,

I try to implement the script below but unity say :

`Vuforia.VuforiaBehaviour' does not contain a definition for `RegisterTrackablesUpdatedCallback' and no extension method `RegisterTrackablesUpdatedCallback' of type `Vuforia.VuforiaBehaviour' could be found. Are you missing an assembly reference?

 Type `Vuforia.VuforiaBehaviour' does not contain a definition for `RegisterVuforiaStartedCallback' and no extension method `RegisterVuforiaStartedCallback' of type `Vuforia.VuforiaBehaviour' could be found. Are you missing an assembly reference?

 

With this piece of code :

qcarBehavior = GetComponent<VuforiaBehaviour>();
qcarBehavior.RegisterVuforiaStartedCallback(OnInitialized);
qcarBehavior.RegisterTrackablesUpdatedCallback(OnTrackablesUpdated);

Do you know, how i can do this ?

For information I'm on unity 5.5 with Vuforia 6.2.6.

Thanks a lot in advance for your answers

Best regards

Blister

Filter Camera Position and Rotation to avoid jitter?

December 6, 2016 - 5:40am #95

This solution doesn't work with the World Center mode Camera right? Has anyone got it to work for that setup?

 

Is there a way to attach it a gameobject instead of the ARcamera?

 

Filter Camera Position and Rotation to avoid jitter?

November 17, 2016 - 12:30am #94

I think you are using Standard Unity material shader for your augmented objects. Try Mobile>Diffuse or Legacy Diffuse material. Problem of white screen will be resolved

 

Filter Camera Position and Rotation to avoid jitter?

November 17, 2016 - 12:28am #93

@caiopellegrim   I think you are using Standard Unity material shader for your augmented objects. Try Mobile>Diffuse or Legacy Diffuse material. Problem of white screen will be resolved

Filter Camera Position and Rotation to avoid jitter?

November 12, 2016 - 3:25am #92

agreeyamobility wrote:

is it works for: World Center Mode: CAMERA?

 

 

Works or no in Camera mode?

Filter Camera Position and Rotation to avoid jitter?

September 1, 2016 - 4:22am #91

Sorry to bring this up. Im new to vuforia and unity started like 15 days ago. So i had this problem and I used those codes, it worked perfectly. However when i tried to built my apk for android the camera only showed to me a white screen with the vuforia watermark. 

Anyone experienced this too?

Any help will be more then welcome.

Thanks in advance.

Filter Camera Position and Rotation to avoid jitter?

June 13, 2016 - 7:48am #90

is it works for: World Center Mode: CAMERA?

 

Filter Camera Position and Rotation to avoid jitter?

January 20, 2016 - 6:55am #89

Hello,

I have succesfuly implemented smoothing function, but it works only if I look at target spacified as world center.

Other tagets behave like smoothing function isn't used at all.

Filter Camera Position and Rotation to avoid jitter?

January 18, 2016 - 11:19pm #88

It works! Thanks everyone!

Filter Camera Position and Rotation to avoid jitter?

January 18, 2016 - 11:19pm #87

It works! Thanks everyone!

Filter Camera Position and Rotation to avoid jitter?

January 6, 2016 - 10:40pm #86

hey puzzlekings,

 

maybe this link could help you with the Math3d issue: https://gist.github.com/jankolkmeier/8543156

Filter Camera Position and Rotation to avoid jitter?

November 24, 2015 - 7:33am #85

Thanks for this script.

Unfortunately when I try it in Unity, Unity complains about this line:

     Math3d.AverageQuaternion(ref avgrsingleRotationrotations.Peek(), rotations.Count);

...as it seems this does not exist in Unity?

Any ideas or possible solution here?

 

thanks

Nalin

 

EDIT - ok after reading further down it needs Math3D here: https://gist.github.com/jankolkmeier/8543156

 

cheers

Filter Camera Position and Rotation to avoid jitter?

October 30, 2015 - 6:05pm #84

This is the ultimate script working on Vuforia 5.x

 

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<VuforiaBehaviour>();

        qcarBehavior.RegisterVuforiaStartedCallback(OnInitialized);
        qcarBehavior.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 29, 2015 - 8:09pm #83

Thanks Allesandro 

All good:)

Filter Camera Position and Rotation to avoid jitter?

September 29, 2015 - 7:22am #82

Concerning this error:

Assets/Vuforia/Scripts/SmoothCamera.cs(6,44): error CS0246: The type or namespace name `ITrackerEventHandler' could not be found. Are you missing a using directive or an assembly reference?

you just need to add this line at the top of your scripts:

using Vuforia;

 

Filter Camera Position and Rotation to avoid jitter?

September 29, 2015 - 5:41am #81

I'm having the same issues...

When I build a new projet in unity, add to the empty scene the prefabs: ARCamera and ImageTarget, I drag a simple cube on the Image target.
Once the ARCamera and the Image target are set up, if I press play on really recent i7 iMac or on an ipad air 2, the 3D object (a cube) starts shaking violently.

I saw that the vuforia winner app, Rolls Royce, stays and remains still. What are they doing differently ? I've been using vuforia for years, I just followed your tutorial, and play with the simpliest scene as possible in unity and it's unusable. Our client sent us back the first draw of our project because of the violent shakings... Every update seems to bring more problems than the previous one.

Any one from vuforia to help us on that ? This should work straight out the box...

 

When I try your code I get the same errors as you do. Waiting for some help too on that one...

Filter Camera Position and Rotation to avoid jitter?

September 29, 2015 - 5:41am #80

I'm having the same issues...

When I build a new projet in unity, add to the empty scene the prefabs: ARCamera and ImageTarget, I drag a simple cube on the Image target.
Once the ARCamera and the Image target are set up, if I press play on really recent i7 iMac or on an ipad air 2, the 3D object (a cube) starts shaking violently.

I saw that the vuforia winner app, Rolls Royce, stays and remains still. What are they doing differently ? I've been using vuforia for years, I just followed your tutorial, and play with the simpliest scene as possible in unity and it's unusable. Our client sent us back the first draw of our project because of the violent shakings... Every update seems to bring more problems than the previous one.

Any one from vuforia to help us on that ? This should work straight out the box...

 

When I try your code I get the same errors as you do. Waiting for some help too on that one...

Filter Camera Position and Rotation to avoid jitter?

September 22, 2015 - 3:52pm #79

Thanks, but still having trouble.

I now receive this error message:

Assets/Vuforia/Scripts/SmoothCamera.cs(6,44): error CS0246: The type or namespace name `ITrackerEventHandler' could not be found. Are you missing a using directive or an assembly reference?

Is the following correct?:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

[RequireComponent(typeof (VuforiaBehaviour))]
public class SmoothCamera : MonoBehaviourITrackerEventHandler  {

    public int smoothingFrames = 10;
    private VuforiaBehaviour qcarBehavior;

    private Quaternion smoothedRotation;
    private Vector3 smoothedPosition;

    private Queue<Quaternionrotations;
    private Queue<Vector3positions;

    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 avgrsingleRotationrotations.Peek(), rotations.Count);
        }

        Vector3 avgp = Vector3.zero;
        foreach (Vector3 singlePosition in positions) {
            avgp += singlePosition;
        }
        avgp /= positions.Count;

        smoothedRotation = new Quaternion(avgr.xavgr.yavgr.zavgr.w);
        smoothedPosition = avgp;
    }

    // Use this for initialization
    void Start () {
        rotations = new Queue<Quaternion>(smoothingFrames);
        positions = new Queue<Vector3>(smoothingFrames);
        qcarBehavior = GetComponent<VuforiaBehaviour>();
        qcarBehavior.RegisterTrackerEventHandler(this);
    
    }
    
    // Update is called once per frame
    void LateUpdate () {
        transform.rotation = smoothedRotation;
        transform.position = smoothedPosition;
    }

}

Filter Camera Position and Rotation to avoid jitter?

September 22, 2015 - 1:10am #78

If you are using Vuforia 5.0, you need to replace "QCARBehaviour" with "VuforiaBehaviour"; for a complete overview of class / method names changes in Vuforia 5, see:

https://developer.vuforia.com/library/articles/Solution/Vuforia-5-Migration

and

https://developer.vuforia.com/library/articles/Solution/Migrating-Unity-Projects-to-Vuforia-5

 

Filter Camera Position and Rotation to avoid jitter?

September 21, 2015 - 11:43pm #77

Hi,

 

When I attempt to install this I now receive this message:

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

 

Can anyone help:)

 

Filter Camera Position and Rotation to avoid jitter?

June 19, 2015 - 1:13am #76

How To avoid Jitter when World Center Mode is Camera... The below script works when World Center Mode is First_target....

Thank you in Advance

Filter Camera Position and Rotation to avoid jitter?

May 6, 2015 - 8:11am #75

I think that warning message is self-explanatory; it says that instead of implementing the ITrackerEventHandler interface in your class (i.e. the OnTrackablesUpdated and OnInitialized methods), you should use 

QCARBehaviour.RegisterQCARStartedCallback ( your_callback_method_1 )

and

QCARBehaviour.RegisterTrackablesUpdatedCallback ( your_callback_method_2 )

you can re-use the methods that you already have (OnTrackablesUpdated and OnInitialized), but simply register them with:

QCARBehaviour.RegisterQCARStartedCallback ( OnInitialized ) 

QCARBehaviour.RegisterTrackablesUpdatedCallback ( OnTrackablesUpdated )

and remove the ITrackerEventHandler interface from your class declaration.

 

Filter Camera Position and Rotation to avoid jitter?

May 6, 2015 - 8:11am #74

I think that warning message is self-explanatory; it says that instead of implementing the ITrackerEventHandler interface in your class (i.e. the OnTrackablesUpdated and OnInitialized methods), you should use 

QCARBehaviour.RegisterQCARStartedCallback ( your_callback_method_1 )

and

QCARBehaviour.RegisterTrackablesUpdatedCallback ( your_callback_method_2 )

you can re-use the methods that you already have (OnTrackablesUpdated and OnInitialized), but simply register them with:

QCARBehaviour.RegisterQCARStartedCallback ( OnInitialized ) 

QCARBehaviour.RegisterTrackablesUpdatedCallback ( OnTrackablesUpdated )

and remove the ITrackerEventHandler interface from your class declaration.

 

Filter Camera Position and Rotation to avoid jitter?

May 6, 2015 - 2:06am #73

In new API of Vuforia I receive this warning:

 

Assets/Scripts/SmoothCamera.cs(49,30): warning CS0618: `Vuforia.QCARAbstractBehaviour.RegisterTrackerEventHandler(Vuforia.ITrackerEventHandler)' is obsolete: `The ITrackerEventHandler interface will be removed with the next Vuforia release. Please use QCARBehaviour.RegisterQCARStartedCallback and RegisterTrackablesUpdatedCallback instead.'

Filter Camera Position and Rotation to avoid jitter?

March 21, 2015 - 11:16pm #72

for you, and anyone else who comes looking it's pretty simple

go to 

https://gist.github.com/jankolkmeier/8543156

download the gist,

drop files into assets folder in unity editor 

Drag smoothcamera.cs onto the ARcamera in your scene.

Set smooth amount in inspector.

 

However!

 

You may need to make a few tweaks if you're using 4.+ This code throws some showstopping errors, below is how I figured out how to get it working.

You need to edit SmootCamera.CS,

Firstly add Vuforia. to QCARBehaviour and ITrackerEventHandler like below

From

[RequireComponent(typeof (QCARBehaviour))]
public class SmoothCamera : MonoBehaviour,ITrackerEventHandler  {

    public int smoothingFrames = 10;
    private QCARBehaviour qcarBehavior;

to

[RequireComponent(typeof (Vuforia.QCARBehaviour))]
public class SmoothCamera : MonoBehaviourVuforia.ITrackerEventHandler  {

    public int smoothingFrames = 10;
    private Vuforia.QCARBehaviour qcarBehavior;

 

also in void start remove the 'true' at the end

 

from

    // Use this for initialization
          void Start () {
        rotations = new Queue<Quaternion>(smoothingFrames);
        positions = new Queue<Vector3>(smoothingFrames);
        qcarBehavior = GetComponent<Vuforia.QCARBehaviour>();
       qcarBehavior.RegisterTrackerEventHandler(this, true);
}

 

To

 

    // Use this for initialization

          void Start () {
        rotations = new Queue<Quaternion>(smoothingFrames);
        positions = new Queue<Vector3>(smoothingFrames);
        qcarBehavior = GetComponent<Vuforia.QCARBehaviour>();
       qcarBehavior.RegisterTrackerEventHandler(this);
}

hopefully this gets addressed in coming releases, but this is an acceptable solution to camera judder for now

thanks to jank below for code

Filter Camera Position and Rotation to avoid jitter?

January 24, 2015 - 8:24pm #71

Would anyone be able to give a step by step on implementation of the Math3d.cs and SmoothCamera.cs scripts in Unity3D?  Would be much obliged!

 

Cheers!

Log in or register to post comments