use of georegression.struct.shapes.Rectangle2D_F64 in project BoofCV by lessthanoptimal.
the class Tld_to_TrackerObjectQuad method process.
@Override
public boolean process(T image, Quadrilateral_F64 results) {
if (!tracker.track(image))
return false;
Rectangle2D_F64 rect = tracker.getTargetRegion();
results.a.x = rect.p0.x;
results.a.y = rect.p0.y;
results.b.x = rect.p1.x;
results.b.y = rect.p0.y;
results.c.x = rect.p1.x;
results.c.y = rect.p1.y;
results.d.x = rect.p0.x;
results.d.y = rect.p1.y;
return true;
}
use of georegression.struct.shapes.Rectangle2D_F64 in project narchy by automenta.
the class WebcamObjectTrack method process.
/**
* Invoke to start the main processing loop.
*/
public void process() {
Webcam webcam = UtilWebcamCapture.openDefault(desiredWidth, desiredHeight);
// adjust the window size and let the GUI know it has changed
Dimension actualSize = webcam.getViewSize();
setPreferredSize(actualSize);
setMinimumSize(actualSize);
window.setMinimumSize(actualSize);
window.setPreferredSize(actualSize);
window.setVisible(true);
// create
T input = tracker.getImageType().createImage(actualSize.width, actualSize.height);
workImage = new BufferedImage(input.getWidth(), input.getHeight(), BufferedImage.TYPE_INT_RGB);
ImageFloat32 inputFloat = new ImageFloat32(actualSize.width, actualSize.height);
while (true) {
BufferedImage buffered = webcam.getImage();
ConvertBufferedImage.convertFrom(webcam.getImage(), input, true);
// mode is read/written to by the GUI also
int mode = this.mode;
boolean success = false;
if (mode == 2) {
Rectangle2D_F64 rect = new Rectangle2D_F64();
rect.set(point0.x, point0.y, point1.x, point1.y);
UtilPolygons2D_F64.convert(rect, target);
success = tracker.initialize(input, target);
this.mode = success ? 3 : 0;
} else if (mode == 3) {
success = tracker.process(input, target);
}
synchronized (workImage) {
// copy the latest image into the work buffered
Graphics2D g2 = workImage.createGraphics();
g2.drawImage(buffered, 0, 0, null);
ConvertBufferedImage.convertFrom(buffered, inputFloat);
fitCannyBinary(inputFloat, g2);
// visualize the current results
if (mode == 1) {
drawSelected(g2);
} else if (mode == 3) {
if (success) {
drawTrack(g2);
}
}
}
repaint();
}
}
Aggregations