Round() public method

Rounds the single precision point.
public Round ( ) : IntPoint
return IntPoint
Beispiel #1
0
        public void RoundTest( float x, float y, int expectedX, int expectedY )
        {
            Point point = new Point( x, y );
            IntPoint iPoint = new IntPoint( expectedX, expectedY );

            Assert.AreEqual( iPoint, point.Round( ) );
        }
Beispiel #2
0
        private void ProcessFrame()
        {
            _currentPreprocessedImage = _preprocessingFilters.Apply(_currentSourceImage);

            UnmanagedImage sourceCopy = _currentSourceImage.Clone();
            UnmanagedImage output     = UnmanagedImage.Create(sourceCopy.Width, sourceCopy.Height, sourceCopy.PixelFormat);

            if (_previousPreprocessedImage != null)
            {
                //output = _lucasKanade.ShowDerivative(preprocessed, _previous, LucasKanade.DerivativeComponent.X);

                #region Point tracking
                Point centroid = new Point();
                for (int i = 0; i < _trackingPoints.Count; ++i)
                {
                    Point point    = _trackingPoints[i];
                    Point velocity = _tracker.CalculateVelocity(_currentPreprocessedImage, _previousPreprocessedImage, point.Round());

                    UpdatePointPosition(i, velocity);

                    centroid += _trackingPoints[i] / _trackingPoints.Count;

                    Drawing.Rectangle(sourceCopy, new Rectangle((int)point.X - 2, (int)point.Y - 2, 5, 5), Color.Yellow);
                }

                Drawing.Rectangle(sourceCopy, new Rectangle((int)centroid.X - 3, (int)centroid.Y - 3, 7, 7), Color.Red);
                #endregion

                DrawVelocityMap(output);
            }

            _previousPreprocessedImage = _currentPreprocessedImage;

            SourcePictureBox.Image       = sourceCopy.ToManagedImage();
            PreprocessedPictureBox.Image = _currentPreprocessedImage.ToManagedImage();
            if (output != null)
            {
                OutputPictureBox.Image = output.ToManagedImage();
            }
        }
Beispiel #3
0
        public static System.Drawing.Point ToGDIPoint(this AForge.Point point)
        {
            IntPoint intPoint = point.Round();

            return(intPoint.ToGDIPoint());
        }