private void DrawVelocityMap(UnmanagedImage output)
{
Point sumVelocity = new Point();
int indention = 7;
int step = 10;
Invoke(() => step = VelocitiesDistanceTrackBar.Value);
//Point[,] velocityField = ((dynamic)_tracker).CalculateVelocityField(_currentPreprocessedImage, _previousPreprocessedImage);
for (int x = indention; x < _frameSize.Width - indention; x += step)
{
for (int y = indention; y < _frameSize.Height - indention; y += step)
{
IntPoint p = new IntPoint(x, y);
Point velocity = _tracker.CalculateVelocity(_currentPreprocessedImage, _previousPreprocessedImage, p);
//Point velocity = velocityField[y, x];
sumVelocity += velocity;
if (velocity.EuclideanNorm() != 0.0f)
{
IntPoint newp = (p + velocity).Round();
Drawing.Line(output, p, newp, Color.White);
output.SetPixel(newp, Color.Red);
}
}
}
Invoke(() => InfoLabel.Text = string.Format("Summary motion: ({0:+00.00;-00.00}; {1:+00.00;-00.00})", sumVelocity.X / 10, sumVelocity.Y / 10));
}