Exemplo n.º 1
0
  @Test
  public void findFlow() {
    Dummy alg = new Dummy(3, 2, 200, ImageUInt8.class);

    alg.minScore = 0.1f;
    alg.targetX = 4;
    alg.targetY = 8;

    ImageUInt8 image = new ImageUInt8(30, 40);
    ImageFlow.D flow = new ImageFlow.D();

    // see if it selects the obvious minimum
    assertEquals(0.1f, alg.findFlow(6, 7, image, flow), 1e-4);
    assertTrue(flow.valid);
    assertEquals(-2, flow.x, 1e-4);
    assertEquals(1, flow.y, 1e-4);

    // now try the case where the error is too high
    alg.minScore = 100000000f;
    alg.findFlow(6, 7, image, flow);
    assertFalse(flow.valid);

    // now give it a case where everything has the same score.  See if it picks the one with the
    // least motion
    alg.sameScore = true;
    alg.minScore = 0.1f;
    alg.findFlow(6, 7, image, flow);
    assertTrue(flow.valid);
    assertEquals(0, flow.x, 1e-4);
    assertEquals(0, flow.y, 1e-4);
  }