use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound in project BoofCV by lessthanoptimal.
the class ECoCheck_to_FiducialDetector method getControl3D.
@Override
protected List<Point2D3D> getControl3D(int which) {
Objects.requireNonNull(pixelToNorm);
ECoCheckFound found = foundIndexToFound(which);
MarkerShape marker = markerShapes.get(found.markerID);
points2D3D.resetResize(found.corners.size);
ECoCheckUtils utils = detector.getUtils();
// length of the longest side on the marker
double markerLength = Math.max(marker.getWidth(), marker.getHeight());
for (int i = 0; i < found.corners.size; i++) {
PointIndex2D_F64 corner = found.corners.get(i);
Point2D3D p23 = points2D3D.get(i);
utils.cornerToMarker3D(found.markerID, corner.index, p23.location);
pixelToNorm.compute(corner.p.x, corner.p.y, p23.observation);
// Convert the units
p23.location.scale(markerLength);
}
return points2D3D.toList();
}
use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound in project BoofCV by lessthanoptimal.
the class ECoCheck_to_FiducialDetector method detect.
@Override
public void detect(T input) {
detector.process(input);
// Find all the known detections
foundToDetection.reset();
for (int detectionID = 0; detectionID < detector.getFound().size; detectionID++) {
ECoCheckFound found = detector.found.get(detectionID);
if (found.markerID < 0)
continue;
foundToDetection.add(detectionID);
}
ECoCheckUtils utils = detector.getUtils();
Estimate1ofEpipolar computeHomography = FactoryMultiView.homographyTLS();
// Compute homographies for each marker
listMarkerToPixels.reset();
for (int knownIdx = 0; knownIdx < foundToDetection.size; knownIdx++) {
int detectionID = foundToDetection.get(knownIdx);
ECoCheckFound found = detector.found.get(detectionID);
int markerID = found.markerID;
// create a list of pairs from marker coordinates to pixels
pairs.resetResize(found.corners.size);
for (int i = 0; i < found.corners.size; i++) {
PointIndex2D_F64 foundCorner = found.corners.get(i);
// Get location of corner on marker in marker units
utils.cornerToMarker3D(markerID, foundCorner.index, point3);
// Observed pixel coordinate of corner
Point2D_F64 p = found.corners.get(i).p;
pairs.get(i).setTo(point3.x, point3.y, p.x, p.y);
}
// Find the homography that relates the coordinate systems
Homography2D_F64 h = listMarkerToPixels.grow();
if (!computeHomography.process(pairs.toList(), tmp)) {
// well this is unexpected. Let's just silently fail.
CommonOps_DDF3.fill(h, 0);
} else {
DConvertMatrixStruct.convert(tmp, h);
}
}
}
use of boofcv.alg.fiducial.calib.ecocheck.ECoCheckFound in project BoofCV by lessthanoptimal.
the class DetectECoCheckApp method processImage.
@Override
public void processImage(int sourceID, long frameID, BufferedImage buffered, ImageBase input) {
original = ConvertBufferedImage.checkCopy(buffered, original);
GrayF32 gray = (GrayF32) input;
double processingTime;
synchronized (lockAlgorithm) {
long time0 = System.nanoTime();
detector.process(gray);
long time1 = System.nanoTime();
// milliseconds
processingTime = (time1 - time0) * 1e-6;
FastAccess<ECoCheckFound> found = detector.getFound();
synchronized (lockVisualize) {
visualizeUtils.update(detector);
// Copy found chessboard patterns
this.foundPatterns.resetResize(found.size);
for (int i = 0; i < found.size; i++) {
this.foundPatterns.get(i).setTo(found.get(i));
// Sort so that they have some sane order when visualized
Collections.sort(foundPatterns.get(i).corners.toList(), Comparator.comparingInt(a -> a.index));
}
}
System.out.println("found.size=" + found.size);
for (int i = 0; i < found.size; i++) {
ECoCheckFound c = found.get(i);
if (!controlPanel.showAnonymous.value && c.markerID < 0)
continue;
System.out.println("[" + i + "]");
System.out.println(" marker=" + c.markerID);
System.out.println(" rows=" + c.squareRows);
System.out.println(" cols=" + c.squareCols);
System.out.println(" decoded=" + c.decodedCells.size);
}
}
SwingUtilities.invokeLater(() -> {
controlPanel.setImageSize(original.getWidth(), original.getHeight());
controlPanel.setProcessingTimeMS(processingTime);
imagePanel.setBufferedImageNoChange(original);
imagePanel.repaint();
});
}
Aggregations