//Initialse Kalman Filter and Timers private void Start_BTN_Click(object sender, EventArgs e) { if (Start_BTN.Text == "Start") { MouseTrackingArea.Refresh(); InitialiseTimers(100); Start_BTN.Text = "Stop"; } else { StopTimers(); Start_BTN.Text = "Start"; } }
private void KalmanFilterRunner(object sender, EventArgs e) { //Graphics G = Graphics.FromImage(pictureBox1.Image); //Image<Bgr, Byte> gridx = grid; //Not needed PointF inp = new PointF(ix, iy); oup = new PointF[2]; oup = filterPoints(inp); PointF[] pts = oup; MouseCorrected_LBL.Text = "Mouse Position Corrected- X:" + cx.ToString() + " Y:" + cy.ToString(); MousePredicted_LBL.Text = "Mouse Position Predicted- X:" + px.ToString() + " Y:" + py.ToString(); Graphics G = MouseTrackingArea.CreateGraphics(); G.FillEllipse(Brushes.Magenta, cx, cy, 5, 5); G.FillEllipse(Brushes.Cyan, px, py, 5, 5); G.FillEllipse(Brushes.Blue, ix, iy, 5, 5); // Action<PointF, Bgr> drawCross = // delegate(PointF point, Bgr color) // { // gridx.Draw(new Cross2DF(point, 15, 15), color, 1); //}; //drawCross(inp, new Bgr(Color.Black)); //draw current state in White // drawCross(oup[1], new Bgr(Color.Red)); //draw the measurement in Red // drawCross(oup[0], new Bgr(Color.Blue)); //draw the prediction (the next state) in green //gridx.Draw(new LineSegment2DF(inp, oup[0]), new Bgr(Color.Magenta), 1); //Draw a line between the current position and prediction of next position //pictureBox1.Image = gridx.ToBitmap(); }