- Home /
Unity and Leap Motion: Help with Jerkiness of input!
Hello, I just want to use some math equation that helps take out the input jitter from my Leap Motion Controller. Leap Motion Heres the Code:
//Cameras look at angle, up or Down
if (HandOpen(leftHand)) {
camRotateVertically = leftHand.PalmNormal.Pitch;
//Debug.Log (((-camRotateVertically) - 1.5f) * 80.0f);
CameraControl.yAngl = ((-camRotateVertically) - 1.5f) * 80.0f;
}
Unfortunately I am getting some slightly random input when i dont move my hand at all (very minimal BUT its directly controlling the camera, which makes it obvious), i need the camera movement to be very responsive as well, so its just a matter of finding averages? Something along those lines
Thanks for the Help! Daniel
This is C# BTW Just for the record i would like suggestions in C# too thanks!
Just FTR here's the likely replacement technology for LEAP ...
Answer by MartinCA · Oct 01, 2013 at 11:16 PM
Feel free to look at any of the following:
To sum it up briefly:
Average will help you eliminate some of the noise, but will add latency. You'll want to find the sweet spot for your back buffer length to get the best results in terms of reliability/latency.
Apply smoothing to enhance your results.
Another deviation on the said above, which I've used before, would be to create a weighted mean function, where you give less weight to new points of data the higher the delta is from previous points. This helps filter out erratic noise spikes, but has limited effect on subtle noise, and is pretty laggy.
Either way, good luck :)
[Late Edit:] Just noticed you mentioned the issues you encounter stem from subtle continuous noise. In which case, if you haven't done so already, it could be simply solved by adding a minimal treshold and avoiding the headache of improving your signal
"Just noticed you mentioned the issues you encounter stem from subtle continuous noise. In which case, if you haven't done so already, it could be simply solved by adding a $$anonymous$$imal treshold and avoiding the headache of improving your signal"
$$anonymous$$artin, I have fooled extensively with "Leap" and you hit the nail on the head, that's the approach that works.
t's worth noting that all of Leap's unity example code and "convenience code" is utterly, totally, useless trash Just look in their API for the many underlying calls (ie .. "how many millimetres away from the leap device is the user's left penis" etc etc) and proceed from there!
@Fattie @$$anonymous$$artinCA This Threshold you all are talking about is this a simple math equation? Do you have documentation to share? $$anonymous$$aybe some examples? In the mean time ill try to figure out what your talking about :D
Fattie LOL! Yea I started with just simple simple things like velocity roll pitch yaw ect :D but yes the reason why is those example unity projects were made before the devices SD$$anonymous$$ was enhanced for more simple ways to call different things such as Roll (used to be 10 lines of code, now its one :P)
Treshold refers to a $$anonymous$$imum tolerance.
Consider this:
Vector3 currentLeapPosition = GetLeapPositionSomehow();
float d = ( m_previousLeapPosition - currentLeapPosition ).magnitude;
m_previousLeapPosition = currentLeapPosition;
if ( d < m_movementTreshold )
{
return;
}
DoWhateverYouWantToDoWithNewPosition( currentLeapPosition );
Simply sample each frame and retain a 1 frame history. If the change over those two frames is below a $$anonymous$$imal value ( defined in m_movementTreshold ), you simply ignore the movement.
Next all you have to do is adjust your treshold level value to filter out small noise.
I totally threw up a LEAP indiegogo campaign !!
http://answers.unity3d.com/questions/498801/is-there-yet-a-leap-motion-for-unity.html
a few people joined in but unfortunately I didn't get a chance to spend any time building it up.
i have an excellent idea for using Leap in the actual unity editor (nothing to do with your problem, $$anonymous$$, I mean "for us developers" - not for use "in apps") so if I ever get some time I'll work it up a bit more.
Heh! what a world eh
@$$anonymous$$artinCA Okay I see what you mean, this makes good sense, Ill see if I can do that! Thank you!
@Fattie Yes I saw that :P What a small world of devs for Leap lol got $$anonymous$$e off of ebay just started this last month :P
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
iTween Visual Editor Event Call from C# to Javascript 1 Answer
Parent Object Via Code C# 3 Answers