smoothing mouse movement
Asked Answered
W

2

5

I'm developing a software to move the mouse based on certain coordinates which i get from a depth image from kinect. but I have 30 frames/second(images/second) and those coordinates changes with every frame so the mouse keeps moving. My question is,Is there a way to smooth the movement of the mouse ?

Whipstitch answered 25/5, 2012 at 15:0 Comment(3)
Could you provide more information? How much is the jittery movement (large/small)? If it is small - some sort of simple temporal filtering can help. If it is large it probably points to issues with your data/algorithm and cannot be smoothed without rethinking the problem.Heartstricken
As @ananthonline said - we'd need a LOT more context, and without a doubt some sample code. Sounds interesting though - I like problems like this, get some code up.Breakneck
The jitter is small but what I want is to smooth the movement, like when the mouse should go from a position to another. It shows some discontinuity. I want a way to move it like the normal mouse does (I know the normal mouse has a much higher frequency but is there any way to move my cursor similarly?)Whipstitch
Y
5

Yes you can start tracking with some parameters that allows you to make move smoother.
Below is an example code:

        var parameters = new TransformSmoothParameters
        {
            Smoothing = 0.2f,
            Correction = 0.0f,
            Prediction = 0.0f,
            JitterRadius = 1.0f,
            MaxDeviationRadius = 0.5f
        };

        this._sensor.SkeletonStream.Enable(parameters);

You can change Smoothing, Correction, Prediction, JitterRadius, and MaxDeviationRadius to whatever numbers you want.

Yun answered 25/5, 2012 at 17:29 Comment(3)
Fixus, this will only work if the OP is tracking the skeleton - not if he is directly using the depth image to calculate the mouse position.Heartstricken
@ananthonline true that. I should write that. But combining both streams isn`t hard so I thought this is a good thing to write :)Yun
Thanks for the answer, I'm not sure about this but is there a way to map the depth coordinates to a skeleton point and track that one ? if yes please provide me a sample code . Thanks in advanceWhipstitch
A
3

Since you wanted to know about "mapping depth coordinates to skeleton points", you can use the DepthImageFrame's MapToSkeletonPoint() which takes the X and Y values of the depth data and then create a SkeletonPoint. Example:

 SkeletonPoint point = depthFrame.MapToSkeletonPoint(x, y);

Hope this helps!

Affair answered 29/8, 2012 at 2:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.