コード例 #1
0
        public void GetOrderdShapeModelTest(int modelCount)
        {
            //assign
            var finder = new ShapeFinder();
            var random = new Random();
            double[] row = new double[modelCount];
            double[] col = new double[modelCount];
            double[] angle = new double[modelCount];
            double[] score = new double[modelCount];
            row = row.Select(p => random.NextDouble()).ToArray();
            col = col.Select(p => random.NextDouble()).ToArray();
            angle = angle.Select(p => random.NextDouble()).ToArray();
            score = score.Select(p => random.NextDouble()).ToArray();

            var model = new ShapeModel()
            {
                ModelId = new HalconDotNet.HTuple(),
                Row = new HalconDotNet.HTuple(row),
                Col = new HalconDotNet.HTuple(col),
                Angle = new HalconDotNet.HTuple(angle),
                Score = new HalconDotNet.HTuple(score),
            };
            var colMin = model.Col.DArr.Min();

            //act
            var orderedModel = finder.GetOrderdShapeModel(model);

            //assert
            Assert.True(colMin == orderedModel.Col[0].D);
        }
コード例 #2
0
        public void Find_Test()
        {
            //Arrange
            var shapeFinder = new ShapeFinder();
            var shapes      = new List <IShape>
            {
                new Circle(new Point(5, 5), 2),
                new Triangle(new Point(2, 2), new Point(4, 2), new Point(2, 5)),
                new Square(new Point(2, 5), new Point(5, 2)),
                new Triangle(new Point(-10, 2), new Point(-4, 4), new Point(2, 2)),
                new Circle(new Point(-5, 5), 6),
                new Circle(new Point(-1, 1), 10),
                new Circle(new Point(-1, 10), 6),
                new Circle(new Point(-5, -5), 2),
                new Square(new Point(-10, -1), new Point(-1, -10)),
                new Square(new Point(-1, 1), new Point(5, -5)),
                new Circle(new Point(0, 0), 1)
            };
            //Act
            var firstQuarter  = shapeFinder.Find(shapes, Quarter.First).ToList();
            var secondQuarter = shapeFinder.Find(shapes, Quarter.Second).ToList();
            var thirdQuarter  = shapeFinder.Find(shapes, Quarter.Third).ToList();
            var fourthQuarter = shapeFinder.Find(shapes, Quarter.Fourth).ToList();
            var noneQuarter   = shapeFinder.Find(shapes, Quarter.None).ToList();

            //Assert
            Assert.AreEqual(firstQuarter.Count, 3);
            Assert.AreEqual(secondQuarter.Count, 4);
            Assert.AreEqual(thirdQuarter.Count, 2);
            Assert.AreEqual(fourthQuarter.Count, 1);
            Assert.AreEqual(noneQuarter.Count, 1);
        }
コード例 #3
0
        public void GetOrderdShapeModelTest(int modelCount)
        {
            //assign
            var finder = new ShapeFinder();
            var random = new Random();

            double[] row   = new double[modelCount];
            double[] col   = new double[modelCount];
            double[] angle = new double[modelCount];
            double[] score = new double[modelCount];
            row   = row.Select(p => random.NextDouble()).ToArray();
            col   = col.Select(p => random.NextDouble()).ToArray();
            angle = angle.Select(p => random.NextDouble()).ToArray();
            score = score.Select(p => random.NextDouble()).ToArray();

            var model = new ShapeModel()
            {
                ModelId = new HalconDotNet.HTuple(),
                Row     = new HalconDotNet.HTuple(row),
                Col     = new HalconDotNet.HTuple(col),
                Angle   = new HalconDotNet.HTuple(angle),
                Score   = new HalconDotNet.HTuple(score),
            };
            var colMin = model.Col.DArr.Min();

            //act
            var orderedModel = finder.GetOrderdShapeModel(model);

            //assert
            Assert.True(colMin == orderedModel.Col[0].D);
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FindShapes"/> class.
 /// </summary>
 /// <param name="program">Main program.</param>
 public FindShapes(Program program) : base("Find shapes", program)
 {
     _shapeFinder = new ShapeFinder();
     _fileManager = new FileManager();
 }
コード例 #5
0
 void Start()
 {
     shapeFinder  = new ShapeFinder();
     comboCounter = 0;
 }