System.Drawing.Point.Round C# (CSharp) Method

Round() public static method

Converts a PointF to a Point by performing a round operation on all the coordinates.
public static Round ( PointF value ) : Point
value PointF
return Point
        public static Point Round(PointF value) => new Point((int)Math.Round(value.X), (int)Math.Round(value.Y));

Same methods

Point::Round ( System value ) : System.Drawing.Point

Usage Example

Exemplo n.º 1
0
        private void CaptureOnImageGrabbed(object sender, EventArgs eventArgs)
        {
            var capture = (Capture)sender;

            //Show time stamp
            double timeIndex = capture.GetCaptureProperty(CapProp.PosMsec);

            ProgressTime = TimeSpan.FromMilliseconds(timeIndex).ToString("g");

            //show frame number
            double frameNumber = capture.GetCaptureProperty(CapProp.PosFrames);
            double totalFrames = capture.GetCaptureProperty(CapProp.FrameCount);

            _progress = frameNumber / totalFrames;
            RaisePropertyChanged("Progress");

            // Show image with keyPoints
            var frame = new Mat();

            _capture.Retrieve(frame);
            var keyFeatures = _projectFile.Model.GetKeyFeatures((int)frameNumber - 1);

            var imageFrame = new Mat();

            Features2DToolbox.DrawKeypoints(frame, keyFeatures, imageFrame, new Bgr(Color.DarkBlue),
                                            Features2DToolbox.KeypointDrawType.NotDrawSinglePoints);

            if (frameNumber > 1)
            {
                var matches = _projectFile.Model.GetMatches((int)frameNumber - 1);
                foreach (var match in matches)
                {
                    CvInvoke.Line(imageFrame,
                                  Point.Round(match.Item1.Point),
                                  Point.Round(match.Item2.Point),
                                  new Bgr(Color.Red).MCvScalar,
                                  2);
                }
            }

            OriginImage = VideoImageSource = imageFrame;

            //Wait to display correct framerate
            var frameRate = capture.GetCaptureProperty(CapProp.Fps);
            var rightElapsedMilliseconds = 1000.0 / frameRate;
            var realElapsedMilliseconds  = _stopwatch.ElapsedMilliseconds;
            var waitingMilliseconds      = Math.Max(0, rightElapsedMilliseconds - realElapsedMilliseconds);

            Thread.Sleep((int)waitingMilliseconds);
            _stopwatch.Restart();

            if (frameNumber == totalFrames)
            {
                Stop();
            }
        }
All Usage Examples Of System.Drawing.Point::Round