Log in or register to post comments

Filter Camera Position and Rotation to avoid jitter?

January 9, 2014 - 8:20am #70

Hey dvv,

I had to remove your attachment, as your "recompiled" library may break the Vuforia license....

 

Filter Camera Position and Rotation to avoid jitter?

January 9, 2014 - 9:14am #69

Sorry, can i expect the return of this functionality in the next release? On large image targets it is really needed

Filter Camera Position and Rotation to avoid jitter?

January 9, 2014 - 9:26am #68

+1 definitely a good thing...

Filter Camera Position and Rotation to avoid jitter?

January 9, 2014 - 9:52am #67

Are you referring to the ability to apply filters to the pose, or the ability to extend the extension libraries?

Also have you evaluated the Extended Tracking feature yet? - this should help with large scale augmentations. 

Filter Camera Position and Rotation to avoid jitter?

January 9, 2014 - 10:37am #66

About the pose filtering:

The same functionality could be achieved by using the OnTrackablesUpdated callback of the ITrackerEventHandler (by implementing such interface in a script and registering it in QCARBehaviour).
You would just need to remember the poses of the last n frames and set the trackables to averaged/filtered poses in the callback.
 

Filter Camera Position and Rotation to avoid jitter?

January 9, 2014 - 11:12am #65
DavidBeard, yes, only apply filters to the pose. Extended Tracking is awesome feature but sometimes this algorithm add to track unstable points such as people or random items that occasionally appear in frame. And position of marker begin to move relative real marker, this simple to simulate by moving near objects. I can record video tommorow.
 
In this case i think one variant is once save "3d points map" as trackable object for latter use.
 
AlessandroB thank you, realy your method easier)

Filter Camera Position and Rotation to avoid jitter?

January 16, 2014 - 1:05pm #64

AlessandroB wrote:

About the pose filtering:

The same functionality could be achieved by using the OnTrackablesUpdated callback of the ITrackerEventHandler (by implementing such interface in a script and registering it in QCARBehaviour).
You would just need to remember the poses of the last n frames and set the trackables to averaged/filtered poses in the callback.
 

I'm a bit of a novice in this area, could you give me an example of how to access the OnTrackablesUpdated callback? I'm not really sure how to do it when everything is in DLLs.

Filter Camera Position and Rotation to avoid jitter?

January 17, 2014 - 1:11am #63

You simply need to define a script in which you define a class that implements the ITrackerEventHandler interface;

in there, you need to implement the method OnTrackablesUpdated(), which is called whenever the trackas processed the trackables.

The rest is up to you, but I suggest to consult the API reference, as this will help you to use the right API:

https://developer.vuforia.com/resources/api/unity/index

 

Filter Camera Position and Rotation to avoid jitter?

January 17, 2014 - 7:08am #62

Thanks, I'll give that a shot.

Filter Camera Position and Rotation to avoid jitter?

January 21, 2014 - 8:33am #61

I needed the same thing. Since a solution was never posted, here is my (hacked, quick, dirty, yadda yadda, ...) implementation:

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

There are two files.

SmoothCamera.cs is the behavior to be attached to the ARCamera (the one with the QCARBehaviour on it). Here you can set the number of past frames to consider (I recommend not to go too high. 2-5 gives already good filtering without introducing too much delay).

Math3d.cs is just a bunch of helper functions, only some of which are actually needed by SmoothCamera.cs (to calculate an average of several Quaternions).

Maybe it helps someone.

Filter Camera Position and Rotation to avoid jitter?

January 21, 2014 - 8:56am #60

Thank you very much.

And, the Quaternion Averaging and other math functions are much appreciated.

Filter Camera Position and Rotation to avoid jitter?

February 19, 2014 - 3:48am #59

Thank you very much for this example!

Unfortunately, your solution seems to be interfering with Extended Tracking or some other position operations from the last version of Vuforia - smoothing process interrupts the translation of an object performed by Vuforia and drops it into the center of a screen once the target starts going off screen (often causing trouble with recapturing of the object onto the marker once it returns to the view, too).

As about the suggestion by David to evaluate the use of Extended Tracking as a solution for jitter issues - unfortunately, I'm not getting any perpectible difference, the tracking is still noticeably unreliable even with very good images and modestly sized non-offset meshes, so use of a pose filter is still an absolute necessity.

Filter Camera Position and Rotation to avoid jitter?

May 13, 2014 - 3:04am #58

Hey fellas, 

 

Just wondering if there is any more word on this issue?

Filter Camera Position and Rotation to avoid jitter?

May 13, 2014 - 11:47am #57

People keep bothering me because the link is down, it moved here: https://gist.github.com/jankolkmeier/8543156

Filter Camera Position and Rotation to avoid jitter?

May 13, 2014 - 1:32pm #56

People keep bothering me because the link is down, it moved here: https://gist.github.com/jankolkmeier/8543156

Thank you!

Filter Camera Position and Rotation to avoid jitter?

October 19, 2014 - 11:48pm #55

Sir :)

The solution posted by loic_illogika and DavidBeard for the solution for Filter Camera position an Rotation does the same solution also support for the new SDK 3.0.6 . 

Sir Kindly reply ASAP as i desperately need the solution for it. In my application the Plane is rendered which is much larger than the target and I observe continuous shakes. 

Thanks in advanced and waiting for the reply

Filter Camera Position and Rotation to avoid jitter?

October 20, 2014 - 12:27am #54

Is there still a need to add additional scripts as detailed in this thread to prevent object jitter?

My app works a treat and I have extended tracking checked but when holding the device perfectly still the object displayed when tracker is found suffers the described jitter.

I don't being to understand the code that has been posted here, but need to clarify is this still required and for example in the case of Track.cs do I attach that to the camera, the image tracker or the object?

Thanks in advance

 

Filter Camera Position and Rotation to avoid jitter?

October 20, 2014 - 12:33am #53

Did u read or apply one on the  https://gist.github.com/jankolkmeier/8543156

posted by jank. Will it help in my case

 

Filter Camera Position and Rotation to avoid jitter?

October 20, 2014 - 12:33am #52

Did u read or apply one on the  https://gist.github.com/jankolkmeier/8543156

posted by jank. Will it help in my case

 

Filter Camera Position and Rotation to avoid jitter?

January 24, 2015 - 8:24pm #51

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!

Filter Camera Position and Rotation to avoid jitter?

March 21, 2015 - 11:16pm #50

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?

May 6, 2015 - 2:06am #49

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?

May 6, 2015 - 8:11am #48

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 #47

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?

June 19, 2015 - 1:13am #46

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?

September 21, 2015 - 11:43pm #45

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?

September 22, 2015 - 1:10am #44

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 22, 2015 - 3:52pm #43

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 29, 2015 - 5:41am #42

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 #41

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 - 7:22am #40

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 - 8:09pm #39

Thanks Allesandro 

All good:)

Filter Camera Position and Rotation to avoid jitter?

October 30, 2015 - 6:05pm #38

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?

November 24, 2015 - 7:33am #37

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?

January 6, 2016 - 10:40pm #36

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?

January 18, 2016 - 11:19pm #35

It works! Thanks everyone!

Filter Camera Position and Rotation to avoid jitter?

January 18, 2016 - 11:19pm #34

It works! Thanks everyone!

Filter Camera Position and Rotation to avoid jitter?

January 20, 2016 - 6:55am #33

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?

June 13, 2016 - 7:48am #32

is it works for: World Center Mode: CAMERA?

 

Filter Camera Position and Rotation to avoid jitter?

September 1, 2016 - 4:22am #31

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?

November 12, 2016 - 3:25am #30

agreeyamobility wrote:

is it works for: World Center Mode: CAMERA?

 

 

Works or no in Camera mode?

Filter Camera Position and Rotation to avoid jitter?

November 17, 2016 - 12:28am #29

@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 17, 2016 - 12:30am #28

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?

December 6, 2016 - 5:40am #27

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?

January 17, 2017 - 1:05am #26

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?

January 24, 2017 - 11:03am #25

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 29, 2017 - 4:26am #24

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?

February 2, 2017 - 5:53am #23

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?

February 17, 2017 - 11:02pm #22

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?

March 9, 2017 - 9:26am #21

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.

Pages

Log in or register to post comments