use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.
the class TestLensDistortionOps method boundBoxInside_F32.
@Test
public void boundBoxInside_F32() {
// basic sanity check
Affine2D_F32 affine = new Affine2D_F32(1, 1, 0, 1, 1, 2);
PixelTransformAffine_F32 transform = new PixelTransformAffine_F32(affine);
RectangleLength2D_F32 found = LensDistortionOps.boundBoxInside(20, 10, transform);
assertEquals(10, found.x0, 1e-4);
assertEquals(2, found.y0, 1e-4);
assertEquals(20 - 9, found.width, 1e-4);
assertEquals(10, found.height, 1e-4);
}
use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.
the class CirculantVisualizationPanel method update.
public synchronized void update(final CirculantTracker tracker) {
if (hasSelected) {
RectangleLength2D_F32 r = tracker.getTargetLocation();
selected.x0 = (int) r.x0;
selected.y0 = (int) r.y0;
selected.x1 = selected.x0 + (int) r.width;
selected.y1 = selected.y0 + (int) r.height;
GrayF64 template = tracker.getTargetTemplate();
GrayF64 response = tracker.getResponse();
if (this.template == null) {
this.template = new BufferedImage(template.width, template.height, BufferedImage.TYPE_INT_RGB);
this.response = new BufferedImage(template.width, template.height, BufferedImage.TYPE_INT_RGB);
tmp.reshape(template.width, template.height);
}
ConvertImage.convert(template, tmp);
PixelMath.plus(tmp, 0.5f, tmp);
PixelMath.multiply(tmp, 255, 0, 255, tmp);
ConvertBufferedImage.convertTo(tmp, this.template, true);
ConvertImage.convert(response, tmp);
VisualizeImageData.colorizeSign(tmp, this.response, -1);
}
repaint();
}
use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.
the class VisualizeCirculantTrackerApp method process.
public void process(final SimpleImageSequence<T> sequence) {
if (!sequence.hasNext())
throw new IllegalArgumentException("Empty sequence");
image = sequence.next();
gui.setFrame((BufferedImage) sequence.getGuiImage());
ShowImages.showWindow(gui, "Circulant Tracker", true);
// tracker.initialize(image,273,156,358-273,293-156);
paused = true;
while (paused) {
Thread.yield();
}
int totalFrames = 0;
long totalTime = 0;
while (sequence.hasNext()) {
totalFrames++;
image = sequence.next();
gui.setFrame((BufferedImage) sequence.getGuiImage());
long before = System.nanoTime();
tracker.performTracking(image);
long after = System.nanoTime();
totalTime += after - before;
System.out.println("FPS = " + (totalFrames) / (totalTime / 2e9));
gui.update(tracker);
RectangleLength2D_F32 r = tracker.getTargetLocation();
System.out.println("Target: " + r);
gui.repaint();
while (paused) {
Thread.yield();
}
}
System.out.println("DONE");
}
use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F32 method allInsideLeft.
public static void allInsideLeft(int imageWidth, int imageHeight, FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight) {
PointTransformHomography_F32 tranLeft = new PointTransformHomography_F32(rectifyLeft);
RectangleLength2D_F32 bound = LensDistortionOps.boundBoxInside(imageWidth, imageHeight, new PointToPixelTransform_F32(tranLeft));
float scaleX = imageWidth / (float) bound.width;
float scaleY = imageHeight / (float) bound.height;
float scale = (float) Math.max(scaleX, scaleY);
adjustUncalibrated(rectifyLeft, rectifyRight, bound, scale);
}
use of georegression.struct.shapes.RectangleLength2D_F32 in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F32 method allInsideLeft.
public static void allInsideLeft(CameraPinholeRadial paramLeft, FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight, FMatrixRMaj rectifyK) {
// need to take in account the order in which image distort will remove rectification later on
paramLeft = new CameraPinholeRadial(paramLeft);
Point2Transform2_F32 tranLeft = transformPixelToRect(paramLeft, rectifyLeft);
RectangleLength2D_F32 bound = LensDistortionOps.boundBoxInside(paramLeft.width, paramLeft.height, new PointToPixelTransform_F32(tranLeft));
LensDistortionOps.roundInside(bound);
float scaleX = paramLeft.width / (float) bound.width;
float scaleY = paramLeft.height / (float) bound.height;
float scale = (float) Math.max(scaleX, scaleY);
adjustCalibrated(rectifyLeft, rectifyRight, rectifyK, bound, scale);
}
Aggregations