Note that there are some explanatory texts on larger screens.

plurals
  1. POKeep moving mouse cursor while pointing somewhere
    text
    copied!<p>So, i'm trying to create a Kinect application where the mouse is controlled by the movements of the head.</p> <pre><code> if (faceFrame.TrackSuccessful) { var xBase = System.Windows.Forms.Screen.AllScreens[0].Bounds.Width; var yBase = System.Windows.Forms.Screen.AllScreens[0].Bounds.Height; var xCentroTela = xBase / 2; var yCentroTela = yBase / 2; var xInicial = Convert.ToInt32(pontosFace[41].X); var yInicial = Convert.ToInt32(pontosFace[41].Y); if (flagPosicao == 0) { SetCursorPos(xCentroTela, yCentroTela); flagPosicao = 1; } //Works int topofscreen = ((100 * yBase) * yInicial) / (50 * yCentroTela); int leftofscreen = ((100 * xBase) * xInicial) / (50 * xCentroTela); leftofscreen = leftofscreen - xCentroTela; topofscreen = topofscreen - yCentroTela; SetCursorPos(leftofscreen, topofscreen); Thread.Sleep(1); txty.Text = Convert.ToString(topofscreen); txtx.Text = Convert.ToString(leftofscreen); } </code></pre> <p>I've managed to control it, according to exact position of a given point in the face tracked by the Kinect, but this limits the movement of the mouse into a really small area if the person is seated. This only works if the persons keeps moving his head all around a room.</p> <p>My question is: Is there a way to set the position of the mouse cursor dynamically? In other words, i don't want to set it to my exact position. I want to set it to where the tracked point is pointing. For example, if i move my head to the upper-left and stop, the mouse should keep moving in that direction.</p> <p>Or is there a way to increase the tracked point range to larger area?</p> <p><strong>UPDATED</strong> I've updated the code with some improvements. Now, at i'm setting up the mouse cursor to the center of the screen and getting the initial tracked points of the face. Now i'm trying to discover where to go from there.</p> <p><strong>UPDATE #2</strong> Now i've managed to track the central point of the screen(<code>xCentroTela</code>and <code>yCentroTela</code>) and determined the first tracked position of the point (<code>xInicial</code> and <code>yInicial</code>). With that i have set the first tracked position as the center of the screen and trying to go from there. But still having trouble of how mouse to the direction the face is pointing, even using a comparison like the central point of the screen. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload