示例#1
0
  @Test
  public void basic() {
    ImageUInt8 image = new ImageUInt8(400, 500);

    int value = 200;
    ImageMiscOps.fillRectangle(image, value, 20, 30, 40, 40);

    PolygonEdgeScore<ImageUInt8> alg =
        new PolygonEdgeScore<ImageUInt8>(2, 2, 10, value * 0.9, ImageUInt8.class);

    Polygon2D_F64 polygon = new Polygon2D_F64(4);

    UtilPolygons2D_F64.convert(new Rectangle2D_F64(20, 30, 60, 70), polygon);

    alg.setImage(image);
    assertTrue(alg.validate(polygon));
    assertEquals(value, alg.getAverageEdgeIntensity(), 1e-8);

    UtilPolygons2D_F64.convert(new Rectangle2D_F64(24, 30, 60, 70), polygon);

    // test a negative case
    assertFalse(alg.validate(polygon));
    assertEquals(value * 3.0 / 4.0, alg.getAverageEdgeIntensity(), 1e-8);
  }
 public synchronized void setTarget(RectangleLength2D_I32 rect, boolean visible) {
   if (quad != null) UtilPolygons2D_F64.convert(rect, quad);
   mode = Mode.TRACKING;
   targetVisible = visible;
   repaint();
 }