Exemplo n.º 1
0
        public void TestPlanarSubdivision2()
        {
            PointF[] pts = new PointF[33];

             pts[0] = new PointF(224, 432);
             pts[1] = new PointF(368, 596);
             pts[2] = new PointF(316, 428);
             pts[3] = new PointF(244, 596);
             pts[4] = new PointF(224, 436);
             pts[5] = new PointF(224, 552);
             pts[6] = new PointF(276, 568);
             pts[7] = new PointF(308, 472);
             pts[8] = new PointF(316, 588);
             pts[9] = new PointF(368, 536);
             pts[10] = new PointF(332, 428);
             pts[11] = new PointF(124, 380);
             pts[12] = new PointF(180, 400);
             pts[13] = new PointF(148, 360);
             pts[14] = new PointF(148, 416);
             pts[15] = new PointF(128, 372);
             pts[16] = new PointF(124, 392);
             pts[17] = new PointF(136, 412);
             pts[18] = new PointF(156, 416);
             pts[19] = new PointF(176, 404);
             pts[20] = new PointF(180, 384);
             pts[21] = new PointF(168, 364);
             pts[22] = new PointF(260, 104);
             pts[23] = new PointF(428, 124);
             pts[24] = new PointF(328, 32);
             pts[25] = new PointF(320, 200);
             pts[26] = new PointF(268, 76);
             pts[27] = new PointF(264, 144);
             pts[28] = new PointF(316, 196);
             pts[29] = new PointF(384, 196);
             pts[30] = new PointF(424, 136);
             pts[31] = new PointF(412, 68);
             pts[32] = new PointF(348, 32);

             PlanarSubdivision subdiv = new PlanarSubdivision(pts);
             for (int i = 0; i < pts.Length; i++)
             {
            MCvSubdiv2DEdge? edge;
            MCvSubdiv2DPoint? point;
            CvEnum.Subdiv2DPointLocationType location = subdiv.Locate(ref pts[i], out edge, out point);
            if (location == Emgu.CV.CvEnum.Subdiv2DPointLocationType.ON_EDGE)
            {
               //you might want to store the points which is not inserted here.
               //or alternatively, add some random noise to the point and re-insert it again.
               continue;
            }
            subdiv.Insert(pts[i]);
             }

             VoronoiFacet[] facets = subdiv.GetVoronoiFacets();
        }