private bool FindNewCornersAndCheckAspectRatio(List <IntPoint> corners)
        {
            Point    g = PointsCloud.GetCenterOfGravity(corners);
            IntPoint p1 = corners[0], p2 = corners[1], p3 = corners[2], p4 = corners[3];

            List <IntPoint> leftPoints  = new List <IntPoint>();
            List <IntPoint> rightPoints = new List <IntPoint>();

            foreach (IntPoint p in corners)
            {
                if (p.X < g.X)
                {
                    leftPoints.Add(p);
                }
                else
                {
                    rightPoints.Add(p);
                }
            }

            if (leftPoints.Count - rightPoints.Count != 0)
            {
                return(false);
            }
            // korekcija
            if (leftPoints[0].Y < leftPoints[1].Y)
            {
                p4 = leftPoints[0];
                p1 = leftPoints[1];
            }
            else
            {
                p4 = leftPoints[1];
                p1 = leftPoints[0];
            }

            if (rightPoints[0].Y < rightPoints[1].Y)
            {
                p3 = rightPoints[0];
                p2 = rightPoints[1];
            }
            else
            {
                p3 = rightPoints[1];
                p2 = rightPoints[0];
            }

            corners[0] = p4;
            corners[1] = p3;
            corners[2] = p2;
            corners[3] = p1;

            float topSideWidth          = p1.DistanceTo(p2);
            float rightSideHeight       = p3.DistanceTo(p2);
            float ar = topSideWidth / rightSideHeight;

            return(2 <= ar && ar <= 10);
        }
Пример #2
0
            }                                                                   // (needed in drawing, avoid calculating twice)

            public Component(Accord.Point centr, double alignmnt, List <IntPoint> outln,
                             LineSegment lngst, Accord.Point Nstart, Accord.Point Nend)
            {
                Center      = centr;
                Alignment   = alignmnt;
                Outline     = outln;
                Longest     = lngst;
                NormalStart = Nstart;
                NormalEnd   = Nend;
            }
 private bool isPointWithinEdge(Accord.Point point1, Edge edge1)
 {
     if ((point1.X > edge1.positionBeginning[0] && point1.X < edge1.positionEnd[0]) ||
         (point1.X <edge1.positionBeginning[0] && point1.X> edge1.positionEnd[0]))
     {
         if ((point1.Y > edge1.positionBeginning[1] && point1.Y < edge1.positionEnd[1]) ||
             (point1.Y <edge1.positionBeginning[1] && point1.Y> edge1.positionEnd[1]))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Пример #4
0
        private void FindNewCorners(List<IntPoint> corners) {
            // Centar gravitacije unutar kvadrata
            Accord.Point g = PointsCloud.GetCenterOfGravity(corners);
            // Pošto se radi o kvadratu to je 
            IntPoint p1 = corners[0], p2 = corners[1], p3 = corners[2], p4 = corners[3];
            // gdje je: p1 - top left, p2 - top right, p3 - bottom right, p4 - bottom left

            foreach (IntPoint p in corners) {
                if (p.X <= g.X && p.Y >= g.Y)
                    p1 = p;
                else if (p.X >= g.X && p.Y >= g.Y)
                    p2 = p;
                else if (p.X >= g.X && p.Y <= g.Y)
                    p3 = p;
                else if (p.X <= g.X && p.Y <= g.Y)
                    p4 = p;
            }

            corners[0] = p4;
            corners[1] = p3;
            corners[2] = p2;
            corners[3] = p1;
        }
Пример #5
0
 public static Rg.Point3d ToRhPoint(this Ac.Point input, int transposition = 0)
 {
     return(new Rg.Point3d(input.X, transposition - input.Y, 0));
 }