private static void TestMeanShapeImpl(ShapeModel shapeModel, double eps) { Size imageSize = new Size(100, 160); Shape meanShape = shapeModel.FitMeanShape(imageSize.Width, imageSize.Height); // Check GDT vs usual approach double energy = TestShapeEnergyCalculationApproachesImpl( shapeModel, meanShape.VertexPositions, meanShape.EdgeWidths, imageSize, 3501, 1001, eps); // Check if energy is zero Assert.AreEqual(0, energy, eps); // Check if shape is inside given rect); foreach (Vector vertex in meanShape.VertexPositions) Assert.IsTrue(new RectangleF(0, 0, imageSize.Width, imageSize.Height).Contains((float)vertex.X, (float)vertex.Y)); }
public void TestLengthAngleRepresentation() { ShapeModel model = TestHelper.CreateLetterShapeModel(); Shape meanShape = model.FitMeanShape(100, 100); ShapeLengthAngleRepresentation lengthAngleRepresentation = meanShape.GetLengthAngleRepresentation(); Shape meanShape2 = model.BuildShapeFromLengthAngleRepresentation(lengthAngleRepresentation); for (int i = 0; i < model.Structure.VertexCount; ++i) { Assert.AreEqual(meanShape.VertexPositions[i].X, meanShape2.VertexPositions[i].X, 1e-6); Assert.AreEqual(meanShape.VertexPositions[i].Y, meanShape2.VertexPositions[i].Y, 1e-6); } for (int i = 0; i < model.Structure.Edges.Count; ++i) { Assert.AreEqual(meanShape.EdgeWidths[i], meanShape2.EdgeWidths[i], 1e-6); } }
private static void TestMeanShapeImpl(ShapeModel shapeModel, double eps) { Size imageSize = new Size(100, 160); Shape meanShape = shapeModel.FitMeanShape(imageSize.Width, imageSize.Height); // Check GDT vs usual approach double energy = TestShapeEnergyCalculationApproachesImpl( shapeModel, meanShape.VertexPositions, meanShape.EdgeWidths, imageSize, 3501, 1001, eps); // Check if energy is zero Assert.AreEqual(0, energy, eps); // Check if shape is inside given rect); foreach (Vector vertex in meanShape.VertexPositions) { Assert.IsTrue(new RectangleF(0, 0, imageSize.Width, imageSize.Height).Contains((float)vertex.X, (float)vertex.Y)); } }
private static void GenerateMeanShape() { ShapeModel shapeModel = CreateLetterShapeModel(); Shape shape = shapeModel.FitMeanShape(100, 200); }