use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.
the class DistortImageOps method boundBox_F32.
/**
* Finds an axis-aligned bounding box which would contain a image after it has been transformed.
* The returned bounding box can be larger then the original image.
*
* @param srcWidth Width of the source image
* @param srcHeight Height of the source image
* @param transform Transform being applied to the image
* @return Bounding box
*/
public static RectangleLength2D_F32 boundBox_F32(int srcWidth, int srcHeight, PixelTransform2_F32 transform) {
ImageRectangle_F32 r = new ImageRectangle_F32();
r.x0 = r.y0 = Float.MAX_VALUE;
r.x1 = r.y1 = -Float.MAX_VALUE;
for (int y = 0; y < srcHeight; y++) {
transform.compute(0, y);
updateBoundBox(transform, r);
transform.compute(srcWidth, y);
updateBoundBox(transform, r);
}
for (int x = 0; x < srcWidth; x++) {
transform.compute(x, 0);
updateBoundBox(transform, r);
transform.compute(x, srcHeight);
updateBoundBox(transform, r);
}
return new RectangleLength2D_F32(r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0);
}
use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.
the class TestDistortImageOps method boundBox_F32.
@Test
public void boundBox_F32() {
// basic sanity check
Affine2D_F32 affine = new Affine2D_F32(1, 0, 0, 1, 2, 3);
PixelTransformAffine_F32 transform = new PixelTransformAffine_F32(affine);
RectangleLength2D_F32 found = DistortImageOps.boundBox_F32(10, 20, transform);
assertEquals(2, found.x0, 1e-4);
assertEquals(3, found.y0, 1e-4);
assertEquals(10, found.width, 1e-4);
assertEquals(20, found.height, 1e-4);
}
use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.
the class Circulant_to_TrackerObjectQuad method process.
@Override
public boolean process(T image, Quadrilateral_F64 results) {
tracker.performTracking(image);
RectangleLength2D_F32 r = tracker.getTargetLocation();
if (r.x0 >= image.width || r.y0 >= image.height)
return false;
if (r.x0 + r.width < 0 || r.y0 + r.height < 0)
return false;
float x0 = r.x0;
float y0 = r.y0;
float x1 = r.x0 + r.width;
float y1 = r.y0 + r.height;
results.a.x = x0;
results.a.y = y0;
results.b.x = x1;
results.b.y = y0;
results.c.x = x1;
results.c.y = y1;
results.d.x = x0;
results.d.y = y1;
return true;
}
Aggregations