Search in sources :

Example 21 with RectangleLength2D_I32

use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.

the class TestRefinePolygonToContour method basic.

@Test
public void basic() {
    RectangleLength2D_I32 rect = new RectangleLength2D_I32(0, 0, 10, 5);
    List<Point2D_I32> contour = rectToContour(rect);
    GrowQueue_I32 vertexes = computeContourVertexes(rect);
    RefinePolygonToContour alg = new RefinePolygonToContour();
    Polygon2D_F64 found = new Polygon2D_F64();
    alg.process(contour, vertexes, found);
    assertTrue(checkPolygon(new double[] { 0, 0, 9, 0, 9, 4, 0, 4 }, found));
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Point2D_I32(georegression.struct.point.Point2D_I32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 22 with RectangleLength2D_I32

use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.

the class TestSplitMergeLineFitLoop method simpleSquareAll.

/**
 * Sees if it can segment a square.
 */
@Test
public void simpleSquareAll() {
    List<Point2D_I32> contour = rectToContour(new RectangleLength2D_I32(0, 0, 10, 5));
    SplitMergeLineFitLoop alg = new SplitMergeLineFitLoop(0.15, MINIMUM_LENGTH, 100);
    alg.process(contour, splits);
    matchSplitsToExpected(new int[] { 8, 12, 21, 25 }, splits);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Example 23 with RectangleLength2D_I32

use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.

the class DistortImageOps method boundBox.

/**
 * Finds an axis-aligned bounding box which would contain a image after it has been transformed.
 * A sanity check is done to made sure it is contained inside the destination image's bounds.
 * If it is totally outside then a rectangle with negative width or height is returned.
 *
 * @param srcWidth Width of the source image
 * @param srcHeight Height of the source image
 * @param dstWidth Width of the destination image
 * @param dstHeight Height of the destination image
 * @param transform Transform being applied to the image
 * @return Bounding box
 */
public static RectangleLength2D_I32 boundBox(int srcWidth, int srcHeight, int dstWidth, int dstHeight, PixelTransform2_F32 transform) {
    RectangleLength2D_I32 ret = boundBox(srcWidth, srcHeight, transform);
    int x0 = ret.x0;
    int y0 = ret.y0;
    int x1 = ret.x0 + ret.width;
    int y1 = ret.y0 + ret.height;
    if (x0 < 0)
        x0 = 0;
    if (x1 > dstWidth)
        x1 = dstWidth;
    if (y0 < 0)
        y0 = 0;
    if (y1 > dstHeight)
        y1 = dstHeight;
    return new RectangleLength2D_I32(x0, y0, x1 - x0, y1 - y0);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32)

Example 24 with RectangleLength2D_I32

use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.

the class TestDistortImageOps method boundBox.

@Test
public void boundBox() {
    // basic sanity check
    Affine2D_F32 affine = new Affine2D_F32(1, 0, 0, 1, 2, 3);
    PixelTransformAffine_F32 transform = new PixelTransformAffine_F32(affine);
    RectangleLength2D_I32 found = DistortImageOps.boundBox(10, 20, transform);
    assertEquals(2, found.x0);
    assertEquals(3, found.y0);
    assertEquals(10, found.width);
    assertEquals(20, found.height);
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Test(org.junit.Test)

Aggregations

RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)24 Test (org.junit.Test)20 GrayU8 (boofcv.struct.image.GrayU8)16 Planar (boofcv.struct.image.Planar)12 Point2D_I32 (georegression.struct.point.Point2D_I32)5 Affine2D_F32 (georegression.struct.affine.Affine2D_F32)2 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)2 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)2 TrackerMeanShiftLikelihood (boofcv.alg.tracker.meanshift.TrackerMeanShiftLikelihood)1 TrackerObjectQuadPanel (boofcv.gui.tracker.TrackerObjectQuadPanel)1 MediaManager (boofcv.io.MediaManager)1 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)1