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));
}
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);
}
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);
}
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);
}
Aggregations