Exemplo n.º 1
0
        private void Export_to_scene_folder(string dir_path)
        {
            TextFile mtxtFile     = new TextFile(dir_path + "\\scene");
            string   GazeDataLine = "pointNumber, pcr_X , pcr_Y , target_X, target_Y,  gaze_before_X , gaze_before_Y,gaze_after_X , gaze_after_Y,gaze_own_X,gaze_own_Y, ,";

            mtxtFile.WriteLine(GazeDataLine);
            for (int i = 0; i < calibPoints.Length; i++)
            {
                AForge.Point gaze_own = CalibExp.EyeToScene_Mapping.Map(pcr[i].X, pcr[i].Y, CalibExp.EyeToScene_Mapping.GazeErrorX, CalibExp.EyeToScene_Mapping.GazeErrorY);

                GazeDataLine =
                    (calibPoints[i] + 1)
                    + "," + pcr[i].X
                    + "," + pcr[i].Y
                    + "," + target_in_image[i].X
                    + "," + target_in_image[i].Y
                    + "," + gaze_before[i].X
                    + "," + gaze_before[i].Y
                    + "," + gaze_after[i].X
                    + "," + gaze_after[i].Y
                    + "," + gaze_own.X
                    + "," + gaze_own.Y

                ;


                mtxtFile.WriteLine(GazeDataLine);
            }
            mtxtFile.CloseFile();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Conversion from System.Drawing.Point to AForge and back
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public SDPoint FromPresentation(SDPoint p)
        {
            APoint po = FromPresentation(new APoint(p.X, p.Y));

            po.Round();
            return(new SDPoint((int)po.X, (int)po.Y));
        }
        public static PointF ToPictureBoxCoordinate(this PictureBox pictureBox, PointF imageCoordinate)
        {
            if (pictureBox.Image == null)
            {
                throw new Exception("Image property is null!");
            }

            if (pictureBox.SizeMode != PictureBoxSizeMode.Zoom)
            {
                throw new NotSupportedException("Only zoom mode is supported!");
            }

            Size imageSize = pictureBox.Image.Size;

            var scale   = Math.Min((float)pictureBox.Width / imageSize.Width, (float)pictureBox.Height / imageSize.Height);
            var offsetX = (float)(pictureBox.Width - imageSize.Width * scale) / 2;
            var offsetY = (float)(pictureBox.Height - imageSize.Height * scale) / 2;

            var pbPt = new PointF
            {
                X = (imageCoordinate.X * scale) + offsetX,
                Y = (imageCoordinate.Y * scale) + offsetY
            };

            return(pbPt);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Estimates LK optical flow.
        /// </summary>
        /// <param name="storage">Used storage. Number of pyramid levels is specified within storage. Use storage to gain performance in video* by 2x! </param>
        /// <param name="prevFeatures">Previous features.</param>
        /// <param name="currFeatures">Current features.</param>
        /// <param name="status">Feature status.</param>
        /// <param name="windowSize">Aperture size.</param>
        /// <param name="iterations">Maximal number of iterations. If <paramref name="minFeatureShift"/> is reached then number of iterations will be lower.</param>
        /// <param name="minFeatureShift">Minimal feature shift in horizontal or vertical direction.</param>
        /// <param name="minEigenValue">Minimal eigen value.
        /// Eigen values could be interpreted as lengths of ellipse's axes.
        /// If zero ellipse turn into line therefore there is no corner.</param>
        public static void EstimateFlow(PyrLKStorage <TColor> storage,
                                        PointF[] prevFeatures, out PointF[] currFeatures,
                                        out KLTFeatureStatus[] status,
                                        int windowSize = 15, int iterations = 30, float minFeatureShift = 0.1f, float minEigenValue = 0.001f)
        {
            var initialEstimate = new PointF[prevFeatures.Length];

            currFeatures = new PointF[prevFeatures.Length];
            status       = new KLTFeatureStatus[prevFeatures.Length];

            var scaledPrevFeatures = prevFeatures.Apply(x => x.DownScale(storage.PyrLevels));
            var usedIndicies       = Enumerable.Range(0, prevFeatures.Length).ToArray();

            for (int pyrLevel = storage.PyrLevels; pyrLevel >= 0; pyrLevel--)
            {
                PointF[]           levelCurrFeatures;
                KLTFeatureStatus[] levelStatus;
                LKOpticalFlow <TColor> .EstimateFlow(storage,
                                                     scaledPrevFeatures.GetAt(usedIndicies), out levelCurrFeatures, out levelStatus,
                                                     windowSize, iterations, minFeatureShift, minEigenValue, initialEstimate, pyrLevel);

                //update data
                currFeatures.SetAt(usedIndicies, levelCurrFeatures);
                status.SetAt(usedIndicies, levelStatus);

                if (pyrLevel != 0)
                {
                    scaledPrevFeatures.ApplyInPlace(usedIndicies, x => x.UpScale());
                    currFeatures.ApplyInPlace(usedIndicies, x => x.UpScale());

                    initialEstimate = Sub(currFeatures, scaledPrevFeatures);
                    usedIndicies    = getValidFeatureIndicies(status);
                }
            }
        }
Exemplo n.º 5
0
        public AForge.Point GetGazeBeforeGesture(out int index, out bool found)
        {
            bool firstStop = true;

            AForge.Point g = new AForge.Point(0, 0);
            index = 0;
            found = false;
            for (int i = 0; i < rectangleGazeData.Count(); i++)
            {
                if (firstStop)
                {
                    if (rectangleGazeData[i].tag != HeadGesture.GestureBasicCharacters.NoMovement.ToString())
                    {
                        firstStop = false;
                    }
                }
                else
                {
                    if (rectangleGazeData[i].tag == HeadGesture.GestureBasicCharacters.NoMovement.ToString())
                    {
                        g     = rectangleGazeData[i].rectangleGaze;
                        index = i;
                        found = true;
                        break;
                    }
                }
            }

            return(g);
        }
Exemplo n.º 6
0
        // Mouse click on the image - accept new point or reject it (depending on mouse button)
        private void pictureBox_MouseClick(object sender, MouseEventArgs e)
        {
            if (pointIndexToLocate != -1)
            {
                pictureBox.Cursor  = Cursors.Default;
                pictureBox.Capture = false;
                statusLabel.Text   = string.Empty;

                if (e.Button == MouseButtons.Left)
                {
                    var x = System.Math.Max(0, System.Math.Min(e.X, imageSize.Width - 1));
                    var y = System.Math.Max(0, System.Math.Min(e.Y, imageSize.Height - 1));

                    imagePoints[pointIndexToLocate] = new AForge.Point(x - imageSize.Width / 2, imageSize.Height / 2 - y);

                    var imagePointTextBox = (TextBox)imagePointsGroupBox.Controls[string.Format("imagePoint{0}Box", pointIndexToLocate + 1)];
                    imagePointTextBox.Text = imagePoints[pointIndexToLocate].ToString();
                }
                else
                {
                    imagePoints[pointIndexToLocate] = pointPreviousValue;
                }

                ClearEstimation();

                pointIndexToLocate = -1;
                pictureBox.Invalidate();
            }
        }
Exemplo n.º 7
0
        // -----------------------
        // Public Constructors
        // -----------------------

        /// <summary>
        ///	RectangleF Constructor
        /// </summary>
        ///
        /// <remarks>
        ///	Creates a RectangleF from PointF and SizeF values.
        /// </remarks>

        public RectangleF(PointF location, SizeF size)
        {
            x      = location.X;
            y      = location.Y;
            width  = size.Width;
            height = size.Height;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Fits the covariance matrix (or 2nd moment matrix) to the ellipse by calculating eigen-vectors and values.
        /// </summary>
        /// <param name="a">[0, 0] value of the covariance matrix.</param>
        /// <param name="b">[0, 1] or [1, 0] value of the covariance matrix.</param>
        /// <param name="c">[1, 1] value of the covariance matrix.</param>
        /// <param name="center">Center of the ellipse.</param>
        /// <param name="success">Returns true if both calculated eigen-values are positive.</param>
        /// <returns>Ellipse.</returns>
        public static Ellipse Fit(double a, double b, double c, PointF center, out bool success)
        {
            var acDiff = a - c;
            var acSum  = a + c;

            //A * X = lambda * X => solve quadratic equation => lambda1/2 = [a + c +/- sqrt((a-c)^2 + 4b^2)]  / 2
            var sqrtDiscriminant = System.Math.Sqrt(acDiff * acDiff + 4 * b * b);

            var eigVal1 = (acSum + sqrtDiscriminant) / 2;
            var eigVal2 = (acSum - sqrtDiscriminant) / 2;

            //A * X = lambda * X => y / x = b / (lambda - c); where lambda is the first eigen-value
            var angle = System.Math.Atan2(2 * b, (acDiff + sqrtDiscriminant));

            success = eigVal1 > 0 && eigVal2 > 0;
            return(new Ellipse
            {
                Center = center,
                Size = new SizeF
                {
                    Width = (float)System.Math.Sqrt(eigVal1) * 4,
                    Height = (float)System.Math.Sqrt(eigVal2) * 4
                },
                Angle = (float)Accord.Extensions.Math.Geometry.Angle.ToDegrees(angle)
            });
        }
Exemplo n.º 9
0
        /// <summary>
        /// Draws LINE 2D template.
        /// </summary>
        /// <typeparam name="TColor">Color type.</typeparam>
        /// <param name="image">Image.</param>
        /// <param name="template">Template.</param>
        /// <param name="offset">Template features drawing offset.</param>
        /// <param name="color">Features color.</param>
        /// <param name="thickness">Line thickness.</param>
        /// <param name="drawOrientations">True to draw features orientations, false to draw plain contour.</param>
        /// <param name="orientationColor">Orientation color.</param>
        public static void Draw <TColor>(this Image <TColor, Byte> image, ITemplate template, PointF offset, TColor color, int thickness = 2,
                                         bool drawOrientations = false, TColor orientationColor = default(TColor))
            where TColor : IColor3
        {
            const float VECTOR_LENGTH = 10; //it needs to be neigborhood * 2

            var circles = template.Features.Select(x => new CircleF
            {
                X      = x.X + offset.X,
                Y      = x.Y + offset.Y,
                Radius = 2
            });

            image.Draw(circles, color, thickness);

            if (drawOrientations)
            {
                float degSpace = 180f / GlobalParameters.NUM_OF_QUNATIZED_ORIENTATIONS;

                var lines = new List <LineSegment2DF>();
                foreach (var f in template.Features)
                {
                    var orientDeg = f.AngleIndex * degSpace;
                    orientDeg += degSpace / 2;

                    var pt   = new PointF(f.X + offset.X, f.Y + offset.Y);
                    var line = getLine((int)orientDeg, VECTOR_LENGTH, pt);

                    lines.Add(line);
                }

                image.Draw(lines, orientationColor, thickness, connectLines: false);
            }
        }
Exemplo n.º 10
0
        // determines whether view ranges should still be considered based on the angle between the view range currently selected and the other view ranges
        // excludes view ranges where the angle is too high
        private List <AForge.Point> ScanForPoints(AForge.Point startingPoint, List <AForge.Point> allPoints, String directionToScan, float angleThreshold)
        {
            List <AForge.Point> pointsToReturn = new List <AForge.Point>();

            // for every center point of the view ranges, determine if the angle between the startingPoint and the center point is small enough to still be considered
            foreach (AForge.Point point in allPoints)
            {
                if (directionToScan == "up" && startingPoint.X >= point.X)
                {
                    pointsToReturn.Add(GetPointsWithinAngle(startingPoint, point, -1, 0, angleThreshold));
                }
                if (directionToScan == "right" && startingPoint.Y >= point.Y)
                {
                    pointsToReturn.Add(GetPointsWithinAngle(startingPoint, point, 0, -1, angleThreshold));
                }
                if (directionToScan == "down" && startingPoint.X <= point.X)
                {
                    pointsToReturn.Add(GetPointsWithinAngle(startingPoint, point, 1, 0, angleThreshold));
                }
                if (directionToScan == "left" && startingPoint.Y <= point.Y)
                {
                    pointsToReturn.Add(GetPointsWithinAngle(startingPoint, point, 0, 1, angleThreshold));
                }
            }

            pointsToReturn.RemoveAll(x => x == new AForge.Point(-1, -1)); // remove all (-1, -1) points
            return(pointsToReturn);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Fits the covariance matrix (or 2nd moment matrix) to the ellipse by calculating eigen-vectors and values.
        /// </summary>
        /// <param name="covMatrix">Covariance matrix (or 2nd moment matrix).</param>
        /// <param name="center">Center of the ellipse.</param>
        /// <returns>Ellipse.</returns>
        public static Ellipse Fit(double[,] covMatrix, PointF center = default(PointF))
        {
            if (covMatrix.ColumnCount() != 2 || covMatrix.RowCount() != 2)
                throw new ArgumentException("Covariance matrix must have the same dimensions, and the dimension length must be 2!");

            return Fit(covMatrix[0, 0], covMatrix[0, 1], covMatrix[1, 1], center);
        }
        public bool DrawCross(Image <Bgr, Byte> InputImage, AForge.Point p, AForge.Point[] ROI, Color color)
        {
            Point pnt = new Point(Convert.ToInt32(p.X), Convert.ToInt32(p.Y));

            if (pnt.X > 0 & pnt.X < InputImage.Width & pnt.Y > 0 & pnt.Y < InputImage.Height)
            {
                Graphics gr2 = Graphics.FromImage(InputImage.Bitmap);

                // Create a new pen.
                Pen pen = new Pen(color);

                // Set the pen's width.
                pen.Width = 2.0F;

                // Set the LineJoin property.
                pen.LineJoin = System.Drawing.Drawing2D.LineJoin.MiterClipped;


                gr2.DrawLine(pen, pnt.X, ROI[0].Y, pnt.X, ROI[3].Y);
                gr2.DrawLine(pen, ROI[0].X, pnt.Y, ROI[1].X, pnt.Y);

                gr2.Dispose();
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private static LineSegment2DF getLine(int derivativeOrientation, PointF centerPoint, float length)
        {
            Vector2D vec = new Vector2D(Angle.ToRadians(derivativeOrientation)).Multiply(length / 2);
            var      p1  = vec.Add(centerPoint);
            var      p2  = vec.Negate().Add(centerPoint);

            return(new LineSegment2DF(p1, p2));
        }
Exemplo n.º 14
0
 /// <summary>
 /// Adds point and <see cref="Vector2D"/>.
 /// </summary>
 /// <param name="point">Point.</param>
 /// <param name="vector">Vector.</param>
 /// <returns> Translated point. </returns>
 public static PointF Add(PointF point, Vector2D vector)
 {
     return(new PointF
     {
         X = point.X + vector.X,
         Y = point.Y + vector.Y
     });
 }
 /// <summary>
 /// Reflect point over reflector point.
 /// </summary>
 private static PointF reflectPoint(PointF pt, PointF reflectorPt)
 {
     return(new PointF
     {
         X = reflectorPt.X + (reflectorPt.X - pt.X),
         Y = reflectorPt.Y + (reflectorPt.Y - pt.Y)
     });
 }
Exemplo n.º 16
0
 /// <summary>
 /// Draws a LINE2D match.
 /// </summary>
 /// <typeparam name="TColor">Image color.</typeparam>
 /// <typeparam name="TTemplate">LINE2D template type.</typeparam>
 /// <param name="image">Image.</param>
 /// <param name="match">Match to draw.</param>
 /// <param name="color">Color for the match.</param>
 /// <param name="thickness">Contour thickness.</param>
 /// <param name="drawOrientations">True to draw orientations. False to draw only template contour.</param>
 /// <param name="orientationColor">Feature orientation color.</param>
 public static void Draw<TColor, TTemplate>(this Image<TColor, Byte> image, Match<TTemplate> match, TColor color, int thickness = 3,
                                            bool drawOrientations = false, TColor orientationColor = default(TColor))
     where TColor: IColor3
     where TTemplate: ITemplate
 {
     PointF offset = new PointF(match.X, match.Y);
     image.Draw(match.Template, offset, color, thickness, drawOrientations, orientationColor);
 }
Exemplo n.º 17
0
        public void pupildata_Update(AForge.Point pupilCenter, int pupilDiameter)
        {
            eyeData[0].pupilCenter   = pupilCenter;
            eyeData[0].pupilDiameter = pupilDiameter;

            //gesture

            headGesture.AddSegment(eyeData[1].pupilCenter, eyeData[0].pupilCenter);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Fits the covariance matrix (or 2nd moment matrix) to the ellipse by calculating eigen-vectors and values.
        /// </summary>
        /// <param name="covMatrix">Covariance matrix (or 2nd moment matrix).</param>
        /// <param name="center">Center of the ellipse.</param>
        /// <returns>Ellipse.</returns>
        public static Ellipse Fit(double[,] covMatrix, PointF center = default(PointF))
        {
            if (covMatrix.ColumnCount() != 2 || covMatrix.RowCount() != 2)
            {
                throw new ArgumentException("Covariance matrix must have the same dimensions, and the dimension length must be 2!");
            }

            return(Fit(covMatrix[0, 0], covMatrix[0, 1], covMatrix[1, 1], center));
        }
Exemplo n.º 19
0
        public static AForge.Point Normalize(this AForge.Point point)
        {
            float dist = point.EuclideanNorm();

            point.X /= dist;
            point.Y /= dist;

            return(point);
        }
Exemplo n.º 20
0
        public AForge.Point CorrectGlintPoint(AForge.Point inp)
        {
            AForge.Point oup = new AForge.Point();

            oup.X = (float)inp.X * glintPyrLevel + glintROI.X;
            oup.Y = (float)inp.Y * glintPyrLevel + glintROI.Y;


            return(oup);
        }
Exemplo n.º 21
0
        private static PointF[] Sub(PointF[] arrA, PointF[] arrB)
        {
            PointF[] diff = new PointF[arrA.Length];

            for (int i = 0; i < diff.Length; i++)
            {
                diff[i] = new PointF(arrA[i].X - arrB[i].X, arrA[i].Y - arrB[i].Y);
            }

            return(diff);
        }
Exemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Blob"/> class.
 /// </summary>
 ///
 /// <param name="source">Source blob to copy.</param>
 ///
 /// <remarks><para>This copy constructor leaves <see cref="Image"/> property not initialized. The blob's
 /// image may be extracted later using <see cref="BlobCounterBase.ExtractBlobsImage( Bitmap, Blob, bool )"/>
 /// or <see cref="BlobCounterBase.ExtractBlobsImage( UnmanagedImage, Blob, bool )"/> method.</para></remarks>
 ///
 public Blob(Blob source)
 {
     // copy everything except image
     id          = source.id;
     rect        = source.rect;
     cog         = source.cog;
     area        = source.area;
     fullness    = source.fullness;
     colorMean   = source.colorMean;
     colorStdDev = source.colorStdDev;
 }
Exemplo n.º 23
0
        public RemoteCalibration(int n, int m, Rectangle rect)
        {
            InitializeComponent();

            ScreenWidth   = rect.Width;
            ScreenHeight  = rect.Height;
            ScreenTopLeft = new AForge.Point((float)rect.Left, (float)rect.Top);

            ChangeForm(rect, "this");
            setPoints(n, m);
        }
        private static RectangleF getFeatureArea(PointF location, int winSize)
        {
            int halfWinSize = winSize / 2;

            return(new RectangleF
            {
                X = location.X - halfWinSize,
                Y = location.Y - halfWinSize,
                Width = winSize,
                Height = winSize
            });
        }
Exemplo n.º 25
0
        public Circile(AForge.Point mittelPunkt, float radius)
        {
            Mittelpunkt_in_Pixel = new PointF(mittelPunkt.X, mittelPunkt.Y);
            Radius_in_Pixel      = radius;

            //Umrechnen
            Radius_in_mm = Radius_in_Pixel * Umrechnung_Pixel_to_mm;

            Mittelpunkt_in_mm = new PointF(
                (Mittelpunkt_in_Pixel.X - ImageMittelpunkt.X) * Umrechnung_Pixel_to_mm,
                (Mittelpunkt_in_Pixel.Y - ImageMittelpunkt.Y) * Umrechnung_Pixel_to_mm);
        }
Exemplo n.º 26
0
        public void RansacLineConstructorTest()
        {
            Point[] points = new Point[500];

            {
                for (int i = 0; i < points.Length; i++)
                {
                    double x = i;
                    double y = i; //+ 5 * Accord.Math.Tools.Random.NextDouble();
                    points[i] = new Point((float)x, (float)y);
                }

                RansacLine target = new RansacLine(0.80, 0.9);

                Line actual = target.Estimate(points);
                Line expected = Line.FromPoints(points[0], points[499]);

                Assert.AreEqual(expected.Slope, actual.Slope, 1e-3);
                Assert.AreEqual(expected.Intercept, actual.Intercept, 1e-2);
            }

            {
                for (int i = 0; i < points.Length; i++)
                {
                    double x = i;
                    double y = i + 5 * Accord.Math.Tools.Random.NextDouble();
                    points[i] = new Point((float)x, (float)y);
                }

                RansacLine target = new RansacLine(0.80, 0.9);

                Line actual = target.Estimate(points);

                Assert.AreEqual(1.0, actual.Slope, 1e-3);
                Assert.AreEqual(0.0, actual.Intercept, 1e-2);
            }

            {
                for (int i = 0; i < points.Length; i++)
                {
                    double x = i + 50;
                    double y = i + 50 + 5 * Accord.Math.Tools.Random.NextDouble();
                    points[i] = new Point((float)x, (float)y);
                }

                RansacLine target = new RansacLine(0.80, 0.9);

                Line actual = target.Estimate(points);

                Assert.AreEqual(1.0, actual.Slope, 1e-3);
                Assert.AreEqual(0.0, actual.Intercept, 1e-2);
            }
        }
Exemplo n.º 27
0
        public void RansacLineConstructorTest()
        {
            Point[] points = new Point[500];

            {
                for (int i = 0; i < points.Length; i++)
                {
                    double x = i;
                    double y = i; //+ 5 * Accord.Math.Tools.Random.NextDouble();
                    points[i] = new Point((float)x, (float)y);
                }

                RansacLine target = new RansacLine(0.80, 0.9);

                Line actual   = target.Estimate(points);
                Line expected = Line.FromPoints(points[0], points[499]);

                Assert.AreEqual(expected.Slope, actual.Slope, 1e-3);
                Assert.AreEqual(expected.Intercept, actual.Intercept, 1e-2);
            }

            {
                for (int i = 0; i < points.Length; i++)
                {
                    double x = i;
                    double y = i + 5 * Accord.Math.Tools.Random.NextDouble();
                    points[i] = new Point((float)x, (float)y);
                }

                RansacLine target = new RansacLine(0.80, 0.9);

                Line actual = target.Estimate(points);

                Assert.AreEqual(1.0, actual.Slope, 1e-3);
                Assert.AreEqual(0.0, actual.Intercept, 1e-2);
            }

            {
                for (int i = 0; i < points.Length; i++)
                {
                    double x = i + 50;
                    double y = i + 50 + 5 * Accord.Math.Tools.Random.NextDouble();
                    points[i] = new Point((float)x, (float)y);
                }

                RansacLine target = new RansacLine(0.80, 0.9);

                Line actual = target.Estimate(points);

                Assert.AreEqual(1.0, actual.Slope, 1e-3);
                Assert.AreEqual(0.0, actual.Intercept, 1e-2);
            }
        }
Exemplo n.º 28
0
        public AForge.Point Map(float inputX, float inputY, float errorX, float errorY)
        {
            AForge.Point output = new AForge.Point();
            switch (CalibrationType)
            {
            case Calibration.calibration_type.calib_Polynomial:

                Matrix <double> A = new Matrix <double>(1, 6);


                double X = inputX;
                double Y = inputY;

                A[0, 0] = 1;
                A[0, 1] = X;
                A[0, 2] = Y;
                A[0, 3] = X * Y;
                A[0, 4] = X * X;
                A[0, 5] = Y * Y;


                output.X = (float)Convert.ChangeType(CvInvoke.cvDotProduct(A.Ptr, PolynomialCoeffs.GetCol(0).Transpose().Ptr), typeof(float));
                output.Y = (float)Convert.ChangeType(CvInvoke.cvDotProduct(A.Ptr, PolynomialCoeffs.GetCol(1).Transpose().Ptr), typeof(float));
                break;

            case Calibration.calibration_type.calib_Homography:


                Matrix <double> src = new Matrix <double>(3, 1);
                Matrix <double> dst = new Matrix <double>(3, 1);


                src[0, 0] = inputX;
                src[1, 0] = inputY;
                src[2, 0] = 1;
                dst       = Homography * src;

                try
                {
                    output.X = (float)Convert.ChangeType(dst[0, 0] / dst[2, 0], typeof(float));
                    output.Y = (float)Convert.ChangeType(dst[1, 0] / dst[2, 0], typeof(float));
                    // System.Diagnostics.Debug.WriteLine(gaze.X + "," + gaze.Y );
                }
                catch (Exception e) { }
                break;
            }

            output.X -= errorX;
            output.Y -= errorY;

            return(output);
        }
Exemplo n.º 29
0
        // find the angle between two points and calculate to see if it is below a certain threshold
        private AForge.Point GetPointsWithinAngle(AForge.Point startingPoint, AForge.Point endPoint, int deltaX, int deltaY, float angleThreshold)
        {
            double angleToConsider = GeometryTools.GetAngleBetweenLines(new AForge.Point(startingPoint.X, startingPoint.Y),
                                                                        new AForge.Point(startingPoint.X + deltaX, startingPoint.Y + deltaY),  // extend the starting point into a line in the appropraite direction as dictated by delta x or delta y
                                                                        new AForge.Point(startingPoint.X, startingPoint.Y),
                                                                        new AForge.Point(endPoint.X, endPoint.Y));                             // line between the starting point and the ending point

            if (angleToConsider < angleThreshold)
            {
                return(endPoint);              // if the angle is smaller than the threshold, return it
            }
            return(new AForge.Point(-1, -1));  // otherwise return the point (-1, -1)
        }
Exemplo n.º 30
0
        /// <summary>
        /// Gets vertices.
        /// </summary>
        /// <param name="useScreenCoordinateSystem">During vertex rotation whether to use standard Cartesian space or screen coordinate space (y-inverted).</param>
        /// <returns>Vertices.</returns>
        public                       PointF[] GetVertices(bool useScreenCoordinateSystem = false)
        {
            PointF center   = this.Center;
            float  angleRad = (float)Accord.Extensions.Math.Geometry.Angle.ToRadians(this.Angle);

            PointF[] nonRotatedVertices = getNonRotatedVertices();
            PointF[] rotatedVertices    = nonRotatedVertices.Select(x => new PointF(x.X - center.X, x.Y - center.Y)) //translate to (0,0)
                                          .Select(x => x.Rotate(angleRad, useScreenCoordinateSystem))                //rotate
                                          .Select(x => new PointF(x.X + center.X, x.Y + center.Y))                   //translate back
                                          .ToArray();

            return(rotatedVertices);
        }
Exemplo n.º 31
0
        public AForge.Point MeasureCenter()
        {
            AForge.Point c = new AForge.Point(0, 0);

            if (eyeData[0].pupilFound)
            {
                //Debug.WriteLine(pupilROI.X + "," + pupilROI.Y);
                c.X = pupilBlobCenter.X + pupilROI.X;
                c.Y = pupilBlobCenter.Y + pupilROI.Y;
            }

            return(c);
        }
Exemplo n.º 32
0
        public void ProcessImage(Bitmap input_image)
        {
            lock (balanceLock)
            {
                int       side     = Math.Min(input_image.Height, input_image.Width);
                Rectangle cropRect = new Rectangle(0, 0, side, side);                                                               // this is square that represents feed from camera
                g.DrawImage(input_image, new Rectangle(0, 0, input_image.Width, input_image.Height), cropRect, GraphicsUnit.Pixel); // place it on original bitmap

                // set new processed
                if (processed != null)
                {
                    processed.Dispose();
                }

                //  Конвертируем изображение в градации серого
                processed = grayFilter.Apply(AForge.Imaging.UnmanagedImage.FromManagedImage(original));
                //  Пороговый фильтр применяем. Величина порога берётся из настроек, и меняется на форме
                threshldFilter.PixelBrightnessDifferenceLimit = ThresholdValue;
                threshldFilter.ApplyInPlace(processed);
                InvertFilter.ApplyInPlace(processed);
                Blober.ProcessImage(processed);
                AForge.Imaging.Blob[] blobs = Blober.GetObjectsInformation();
                BlobCount = blobs.Length;

                if (blobs.Length > 0)
                {
                    var BiggestBlob = blobs[0];
                    Recongnised = true;
                    Blober.ExtractBlobsImage(processed, BiggestBlob, false);
                    processed = BiggestBlob.Image;
                    AForge.Point mc = BiggestBlob.CenterOfGravity;
                    AForge.Point ic = new AForge.Point((float)BiggestBlob.Image.Width / 2, (float)BiggestBlob.Image.Height / 2);
                    AngleRad = (ic.Y - mc.Y) / (ic.X - mc.X);
                    Angle    = (float)(Math.Atan(AngleRad) * 180 / Math.PI);
                }
                else
                {
                    // TODO make arrengaments for No blobs case
                    Recongnised = false;
                    Angle       = 0;
                    AngleRad    = -1;
                }

                if (number != null)
                {
                    number.Dispose();
                }
                number = processed.ToManagedImage();
            }
        }
Exemplo n.º 33
0
        public static AForge.Point GetRedBlobCenter(Bitmap image)
        {
            BlobCounter bCounter = new BlobCounter();
            bCounter.ProcessImage(image);

            Blob[] blobs = bCounter.GetObjectsInformation();
            Rectangle[] rects = bCounter.GetObjectsRectangles();

            Pen pen = new Pen(Color.Red, 2);
            Brush brush = new SolidBrush(Color.Red);
            Graphics g = Graphics.FromImage(image);

            if (rects.Length > 0) { g.FillRectangle(brush, rects[0]); }

            if (blobs.Length > 0)
            {

                detected = true;
                lastPos = blobs[0].CenterOfGravity;

                AForge.Point rPos = new AForge.Point();
                rPos.Y = ((lastPos.Y / 5) / 100) * 768;
                rPos.X = ((lastPos.X / 5) / 100) * 1366;

                return rPos;
            }
            else
            {
                detected = false;
                if (lastPos != null)
                {
                    return lastPos;
                }
                else
                {
                    return new AForge.Point(50.0f, 50.0f);
                }
            }
        }
        public static PointF ToPictureBoxCoordinate(this PictureBox pictureBox, PointF imageCoordinate)
        {
            if (pictureBox.Image == null)
                throw new Exception("Image property is null!");

            if (pictureBox.SizeMode != PictureBoxSizeMode.Zoom)
                throw new NotSupportedException("Only zoom mode is supported!");

            Size imageSize = pictureBox.Image.Size;

            var scale = Math.Min((float)pictureBox.Width / imageSize.Width, (float)pictureBox.Height / imageSize.Height);
            var offsetX = (float)(pictureBox.Width - imageSize.Width * scale) / 2;
            var offsetY = (float)(pictureBox.Height - imageSize.Height * scale) / 2;

            var pbPt = new PointF
            {
                X = (imageCoordinate.X * scale) + offsetX,
                Y = (imageCoordinate.Y * scale) + offsetY
            };

            return pbPt;
        }
        //TODO: this code belongs to point structure
        #region Add point functions 

        /// <summary>
        /// Adds point and <see cref="Vector2D"/>.
        /// </summary>
        /// <param name="point">Point.</param>
        /// <returns> Translated point.</returns>
        public PointF Add(PointF point)
        {
            return Add(point, this);
        }
 /// <summary>
 ///	Contains Method
 /// </summary>
 ///
 /// <remarks>
 ///	Checks if a Point lies within this RectangleF.
 /// </remarks>
 public bool Contains(PointF pt)
 {
     return Contains(pt.X, pt.Y);
 }
Exemplo n.º 37
0
        private void OnPictureBoxClick(object sender, EventArgs e)
        {
            var em = e as MouseEventArgs;
            if (_inSetColor)
            {
                var color = (pictureBox1.Image as Bitmap).GetPixel(em.X, em.Y);
                GlobalVar.Red = color.R;
                GlobalVar.Blue = color.B;
                GlobalVar.Green = color.G;
                processor.SetColor(color);
                _inSetColor = false;
            }
            if (_inSetCenter)
            {
                processor.SetCenter(em.X, em.Y);
                _inSetCenter = false;
                GlobalVar.xOffset = em.X;
                GlobalVar.yOffset = em.Y;
            }
            else
            {
               AForge.Point center = new AForge.Point(240, 160);
               AForge.Point clicked = new AForge.Point(em.X, em.Y);

               var delta = clicked - center;
              _controller.Update(delta.X, delta.Y, true);
            }
        }
Exemplo n.º 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Blob"/> class.
 /// </summary>
 /// 
 /// <param name="source">Source blob to copy.</param>
 /// 
 /// <remarks><para>This copy constructor leaves <see cref="Image"/> property not initialized. The blob's
 /// image may be extracted later using <see cref="BlobCounterBase.ExtractBlobsImage( Bitmap, Blob, bool )"/>
 /// or <see cref="BlobCounterBase.ExtractBlobsImage( UnmanagedImage, Blob, bool )"/> method.</para></remarks>
 /// 
 public Blob( Blob source )
 {
     // copy everything except image
     id   = source.id;
     rect = source.rect;
     cog  = source.cog;
     area = source.area;
     fullness = source.fullness;
     colorMean = source.colorMean;
     colorStdDev = source.colorStdDev;
 }
Exemplo n.º 39
0
 /// <summary>
 /// Fits the covariance matrix (or 2nd moment matrix) to the ellipse by calculating eigen-vectors and values.
 /// </summary>
 /// <param name="a">[0, 0] value of the covariance matrix.</param>
 /// <param name="b">[0, 1] or [1, 0] value of the covariance matrix.</param>
 /// <param name="c">[1, 1] value of the covariance matrix.</param>
 /// <param name="center">Center of the ellipse.</param>
 /// <returns>Ellipse.</returns>
 public static Ellipse Fit(double a, double b, double c, PointF center = default(PointF))
 {
     bool success;
     return Fit(a, b, c, center, out success);
 }
Exemplo n.º 40
0
        private void Recalculate()
        {
            int pointsCount = 4;
            objectScenePoints = new Vector3[pointsCount];
            projectedPoints = new AForge.Point[pointsCount];

            int cx = wImg / 2;
            int cy = hImg / 2;

            for (int i = 0; i < pointsCount; i++)
            {
                objectScenePoints[i] = (perspectiveMatrix *
                                       (viewMatrix *
                                       (worldMatrix * copositObject[i].ToVector4()))).ToVector3();

                projectedPoints[i] = new AForge.Point(
                    (int)(cx * objectScenePoints[i].X),
                    (int)(cy * objectScenePoints[i].Y));
            }
            pktList.Clear();
            for (int i = 0, n = projectedPoints.Length; i < n; i++)
            {
                pktList.Add(new Point((int)(cx + projectedPoints[i].X),
                                             (int)(cy - projectedPoints[i].Y)));
            }
              //          Invalidate();
        }
Exemplo n.º 41
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="imageSize"></param>
        /// <returns></returns>
        public AForge.Point[] PerformProjection()
        {
            // Create the tranformation matrix.
            Matrix4x4 transformationMatrix =
                Matrix4x4.CreateTranslation(this.translationVector) *       // 3: translate
                Matrix4x4.CreateFromRotation(this.rotationMatrix) *         // 2: rotate
                Matrix4x4.CreateDiagonal(
                    new Vector4(
                        this.ModelRadius,
                        this.ModelRadius,
                        this.ModelRadius, 1));                              // 1: scale

            AForge.Point[] projectedPoints = new AForge.Point[this.axesModel.Length];

            for (int i = 0; i < this.axesModel.Length; i++)
            {
                Vector3 scenePoint = (transformationMatrix * this.axesModel[i].ToVector4()).ToVector3();

                projectedPoints[i] = new AForge.Point(
                    (int)(scenePoint.X / scenePoint.Z * this.CoordinateSystemSize.Width),
                    (int)(scenePoint.Y / scenePoint.Z * this.CoordinateSystemSize.Width));
            }

            return projectedPoints;
        }
        private static LineSegment2DF getLine(int derivativeOrientation, PointF centerPoint, float length)
        {
            Vector2D vec = new Vector2D(Angle.ToRadians(derivativeOrientation)).Multiply(length / 2);
            var p1 = vec.Add(centerPoint);
            var p2 = vec.Negate().Add(centerPoint);

            return new LineSegment2DF(p1, p2);
        }
Exemplo n.º 43
0
 /// <summary>
 /// Creates a new instance of an <see cref="CircleF"/> structure.
 /// </summary>
 /// <param name="position">Center position.</param>
 /// <param name="radius">Circle radius.</param>
 public CircleF(PointF position, float radius)
     : this(position.X, position.Y, radius)
 {
 }
 /// <summary>
 ///	Offset Method
 /// </summary>
 ///
 /// <remarks>
 ///	Moves the RectangleF a specified distance.
 /// </remarks>
 public void Offset(PointF pos)
 {
     Offset(pos.X, pos.Y);
 }
 /// <summary>
 /// Constructs an empty model.
 /// </summary>
 public ConstantVelocity2DModel()
 {
     this.Position = default(PointF);
     this.Velocity = default(PointF);
 }
 // -----------------------
 // Public Constructors
 // -----------------------
 /// <summary>
 ///	RectangleF Constructor
 /// </summary>
 ///
 /// <remarks>
 ///	Creates a RectangleF from PointF and SizeF values.
 /// </remarks>
 public RectangleF(PointF location, SizeF size)
 {
     x = location.X;
     y = location.Y;
     width = size.Width;
     height = size.Height;
 }
        /// <summary>
        /// Translates the position of the model.
        /// </summary>
        /// <param name="state">Current state.</param>
        /// <param name="offset">Position offset.</param>
        /// <returns>New state.</returns>
        public static PerspectiveProjection2DModel Translate(this PerspectiveProjection2DModel state, PointF offset)
        {
            var newState = state.Clone();
            newState.ImagePosition.X += offset.X;
            newState.ImagePosition.Y += offset.Y;

            return newState;
        }
 /// <summary>
 /// Constructs an empty model.
 /// </summary>
 public ConstantAcceleration2DModel()
 {
     this.Position = default(PointF);
     this.Velocity = default(PointF);
     this.Acceleration = default(PointF);
 }
Exemplo n.º 49
0
 /// <summary>
 ///   Computes the distance from circle to point.
 /// </summary>
 /// 
 /// <param name="point">The point to have its distance from the circle computed.</param>
 /// 
 /// <returns>The distance from <paramref name="point"/> to this circle.</returns>
 /// 
 public double DistanceToPoint(PointF point)
 {
     var centerDiff = Accord.Math.Distance.Euclidean(X, Y, point.X, point.Y);
     return System.Math.Abs(centerDiff - Radius);
 }
Exemplo n.º 50
0
        /// <summary>
        ///   Creates a new <see cref="Circle"/> from three non-linear points.
        /// </summary>
        /// 
        /// <param name="p1">The first point.</param>
        /// <param name="p2">The second point.</param>
        /// <param name="p3">The third point.</param>
        /// 
        public CircleF(PointF p1, PointF p2, PointF p3)
        {
            // ya = ma * (x - x1) + y1
            // yb = mb * (x - x2) + y2
            //
            // ma = (y2 - y1) / (x2 - x1)
            // mb = (y3 - y2) / (x3 - x2)
            double ma = (p2.Y - p1.Y) / (p2.X - p1.X);
            double mb = (p3.Y - p2.Y) / (p3.X - p2.X);

            //       (ma * mb * (y1 - y3) + mb * (x1 + x2) - ma * (x2 + x3)
            // x = ----------------------------------------------------------
            //                          2 * (mb - ma)
            double x = (ma * mb * (p1.Y - p3.Y) + mb * (p1.X + p2.Y) - ma * (p2.X + p3.X)) / (2 * (mb - ma));
            double y = ma * (x - p1.X) + p1.Y;

            this.X = (float)x;
            this.Y = (float)y;
            this.Radius = (float)Accord.Math.Distance.Euclidean(X, Y, p1.X, p1.Y);
        }
Exemplo n.º 51
0
        /// <summary>
        /// Estemate the 3D position of te glyph.
        /// </summary>
        /// <param name="imageSize">Image size is more like size of the coordinate system.</param>
        /// <param name="useCoplanarPosit"></param>
        /// <param name="yaw"></param>
        /// <param name="pitch"></param>
        /// <param name="roll"></param>
        public void EstimateOrientation(bool useCoplanarPosit, out float yaw, out float pitch, out float roll)
        {
            AForge.Point[] tmpQuadrilateral = new AForge.Point[this.Quadrilateral.Count];

            for (int index = 0; index < this.Quadrilateral.Count; index++)
            {
                tmpQuadrilateral[index] = new AForge.Point(this.Quadrilateral[index].X, this.Quadrilateral[index].Y);
            }

            //
            this.focalLength = this.CoordinateSystemSize.Width;

            // Scale the coordinates
            for (int index = 0; index < tmpQuadrilateral.Length; index++)
            {
                float x = System.Math.Max(0, System.Math.Min(tmpQuadrilateral[index].X, this.CoordinateSystemSize.Width - 1));
                float y = System.Math.Max(0, System.Math.Min(tmpQuadrilateral[index].Y, this.CoordinateSystemSize.Height - 1));

                tmpQuadrilateral[index] = new AForge.Point(x - this.CoordinateSystemSize.Width / 2, this.CoordinateSystemSize.Height / 2 - y);
            }

            // Calculate model's center
            Vector3 modelCenter = new Vector3(
                (modelPoints[0].X + modelPoints[1].X + modelPoints[2].X + modelPoints[3].X) / 4,
                (modelPoints[0].Y + modelPoints[1].Y + modelPoints[2].Y + modelPoints[3].Y) / 4,
                (modelPoints[0].Z + modelPoints[1].Z + modelPoints[2].Z + modelPoints[3].Z) / 4
            );

            // Calculate ~ model's radius.
            this.ModelRadius = 0;
            foreach (Vector3 modelPoint in modelPoints)
            {
                float distanceToCenter = (modelPoint - modelCenter).Norm;
                if (distanceToCenter > this.ModelRadius)
                {
                    this.ModelRadius = distanceToCenter;
                }
            }

            if (!useCoplanarPosit)
            {
                Posit posit = new Posit(modelPoints, focalLength);
                posit.EstimatePose(tmpQuadrilateral, out rotationMatrix, out translationVector);
            }
            else
            {
                CoplanarPosit coposit = new CoplanarPosit(modelPoints, this.focalLength);
                coposit.EstimatePose(tmpQuadrilateral, out rotationMatrix, out translationVector);

                this.bestRotationMatrix = coposit.BestEstimatedRotation;
                this.bestTranslationVector = coposit.BestEstimatedTranslation;

                this.alternateRotationMatrix = coposit.AlternateEstimatedRotation;
                this.alternateTranslationVector = coposit.AlternateEstimatedTranslation;
            }

            // Get the rotation.
            this.rotationMatrix.ExtractYawPitchRoll(out yaw, out pitch, out roll);

            // Transform to degree.
            yaw *= (float)(180.0 / System.Math.PI);
            pitch *= (float)(180.0 / System.Math.PI);
            roll *= (float)(180.0 / System.Math.PI);
        }
Exemplo n.º 52
0
		private async static Task Fisher()
		{
			while (true)
			{

				if (!Fishing)
				{
					await Task.Delay(1000);
					continue;
				}

				TemplateMatch[] m;
				using (var b = Helper.TakeScreenshot(ClickerHeroesHandle))
				using (var s = Helper.Return24bppBitmap(Properties.Resources.Fish2))
					m = b.Contains(s, Dividier: 1, Precision: 0.91f);

				if (m != null)
				{
					foreach (var Match in m)
					{
						var MatchLoc = new Point(Match.Rectangle.X + (Match.Rectangle.Width / 2), Match.Rectangle.Y + (Match.Rectangle.Height / 2));
						Console.WriteLine("Found Fishy at {0}x{1} with {2} similarity", (Int32)MatchLoc.X, (Int32)MatchLoc.Y, Match.Similarity);
						Helper.PostLeftClick(ClickerHeroesHandle,
							Helper.MakeLParam((Int32)MatchLoc.X, (Int32)MatchLoc.Y));
					}
//					var match = m[0];
//					if (match == null) continue;
//					var MatchLoc2 = new Point(match.Rectangle.X, match.Rectangle.Y);
//					MatchLoc2.X += match.Rectangle.Width / 2;
//					MatchLoc2.Y += match.Rectangle.Height / 2;
////
////					
//					Console.WriteLine("Found Fishy at {0}x{1} with {2} similarity", MatchLoc2.X, MatchLoc2.Y, match.Similarity);
//					while (Fishing)
//					{
//						using (var g = Graphics.FromHwnd(ClickerHeroesHandle))
//							g.FillEllipse(Brushes.Red, MatchLoc2.X, MatchLoc2.Y, 5, 5);
//					}

				}

				await Task.Delay(1000);
			}
		}
Exemplo n.º 53
0
        public void DrawPoints(Graphics graphics)
        {
            // Load the points of the glph.
            AForge.Point[] imPoints = new AForge.Point[4];
            for (int index = 0; index < this.Quadrilateral.Count; index++)
            {
                float x = System.Math.Max(0, System.Math.Min(this.Quadrilateral[index].X, this.CoordinateSystemSize.Width - 1));
                float y = System.Math.Max(0, System.Math.Min(this.Quadrilateral[index].Y, this.CoordinateSystemSize.Height - 1));

                imPoints[index] = new AForge.Point(x - this.CoordinateSystemSize.Width / 2, this.CoordinateSystemSize.Height / 2 - y);
            }

            // Calculate the half width and heght.
            int cx = this.CoordinateSystemSize.Width / 2;
            int cy = this.CoordinateSystemSize.Height / 2;

            // Draw corner points.
            for (int i = 0; i < 4; i++)
            {
                using (Brush brush = new SolidBrush(pointsColors[i]))
                {
                    graphics.FillEllipse(brush, new Rectangle(
                        (int)(cx + imPoints[i].X - 3),
                        (int)(cy - imPoints[i].Y - 3),
                        7, 7));
                }
            }
        }
Exemplo n.º 54
0
        private void Recalculate( )
        {
            int pointsCount = objectPoints.Length;
            objectScenePoints = new Vector3[pointsCount];
            projectedPoints = new AForge.Point[pointsCount];

            int cx = ClientRectangle.Width / 2;
            int cy = ClientRectangle.Height / 2;

            for ( int i = 0; i < pointsCount; i++ )
            {
                objectScenePoints[i] = ( perspectiveMatrix *
                                       ( viewMatrix *
                                       ( worldMatrix * objectPoints[i].ToVector4( ) ) ) ).ToVector3( );

                projectedPoints[i] = new AForge.Point(
                    (int) ( cx * objectScenePoints[i].X ),
                    (int) ( cy * objectScenePoints[i].Y ) );
            }

            Invalidate( );
        }
Exemplo n.º 55
0
        /// <summary>
        /// Fits the covariance matrix (or 2nd moment matrix) to the ellipse by calculating eigen-vectors and values.
        /// </summary>
        /// <param name="a">[0, 0] value of the covariance matrix.</param>
        /// <param name="b">[0, 1] or [1, 0] value of the covariance matrix.</param>
        /// <param name="c">[1, 1] value of the covariance matrix.</param>
        /// <param name="center">Center of the ellipse.</param>
        /// <param name="success">Returns true if both calculated eigen-values are positive.</param>
        /// <returns>Ellipse.</returns>
        public static Ellipse Fit(double a, double b, double c, PointF center, out bool success)
        {
            var acDiff = a - c;
            var acSum = a + c;

            //A * X = lambda * X => solve quadratic equation => lambda1/2 = [a + c +/- sqrt((a-c)^2 + 4b^2)]  / 2
            var sqrtDiscriminant = System.Math.Sqrt(acDiff * acDiff + 4 * b * b);

            var eigVal1 = (acSum + sqrtDiscriminant) / 2;
            var eigVal2 = (acSum - sqrtDiscriminant) / 2;

            //A * X = lambda * X => y / x = b / (lambda - c); where lambda is the first eigen-value
            var angle = System.Math.Atan2(2 * b, (acDiff + sqrtDiscriminant));

            success = eigVal1 > 0 && eigVal2 > 0;
            return new Ellipse
            {
                Center = center,
                Size = new SizeF
                {
                    Width = (float)System.Math.Sqrt(eigVal1) * 4,
                    Height =(float)System.Math.Sqrt(eigVal2) * 4
                },
                Angle =  (float)Accord.Extensions.Math.Geometry.Angle.ToDegrees(angle)
            };
        }
 /// <summary>
 /// Creates new <see cref="Vector2D"/> structure.
 /// </summary>
 /// <param name="startPoint">Start point.</param>
 /// <param name="endPoint">End point.</param>
 public Vector2D(PointF startPoint, PointF endPoint)
     : this(endPoint.X - startPoint.X, endPoint.Y - startPoint.Y)
 { }
Exemplo n.º 57
0
 // -----------------------
 // Public Constructors
 // -----------------------
 /// <summary>
 ///	SizeF Constructor
 /// </summary>
 ///
 /// <remarks>
 ///	Creates a SizeF from a PointF value.
 /// </remarks>
 public SizeF(PointF pt)
 {
     width = pt.X;
     height = pt.Y;
 }
 /// <summary>
 /// Adds point and <see cref="Vector2D"/>.
 /// </summary>
 /// <param name="point">Point.</param>
 /// <param name="vector">Vector.</param>
 /// <returns> Translated point. </returns>
 public static PointF Add(PointF point, Vector2D vector)
 {
     return new PointF 
     {
         X = point.X + vector.X,
         Y = point.Y + vector.Y
     };
 }
        private void plotData(PointF point, int seriesIdx, DataPoint dataPointStyle = null, bool markLastPt = true)
        {
            Series s = chart.Series[seriesIdx];

            dataPointStyle = dataPointStyle ?? new DataPoint();

            if (markLastPt)
                tryRemoveLastMarker(seriesIdx, dataPointStyle);

            var dataPt = dataPointStyle.Clone();
            dataPt.XValue = point.X;
            dataPt.YValues = new double[] { point.Y };

            s.Points.Add(dataPt);

            if (markLastPt)
                addMarker(seriesIdx);
        }
Exemplo n.º 60
0
 /// <summary>
 /// Creates new structure from area and angle.
 /// </summary>
 /// <param name="center">Box2D center.</param>
 /// <param name="size">Box 2D size.</param>
 /// <param name="angle">Angle in degrees.</param>
 public Box2D(PointF center, SizeF size, float angle)
 {
     this.Center = new PointF(center.X, center.Y);
     this.Size = size;
     this.Angle = angle;
 }