use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class NonMaxCandidate_MT method examineMinimum.
@Override
protected void examineMinimum(GrayF32 intensityImage, ListIntPoint2D candidates, DogArray<Point2D_I16> found) {
found.reset();
final int stride = intensityImage.stride;
final float[] inten = intensityImage.data;
// little cost to creating a thread so let it select the minimum block size
BoofConcurrency.loopBlocks(0, candidates.size(), searches, (blockData, idx0, idx1) -> {
final Point2D_I16 pt = blockData.pt;
final QueueCorner threadCorners = blockData.corners;
final NonMaxCandidate.Search search = blockData.search;
threadCorners.reset();
search.initialize(intensityImage);
for (int candidateIdx = idx0; candidateIdx < idx1; candidateIdx++) {
candidates.get(candidateIdx, pt);
if (pt.x < ignoreBorder || pt.y < ignoreBorder || pt.x >= endBorderX || pt.y >= endBorderY)
continue;
int center = intensityImage.startIndex + pt.y * stride + pt.x;
float val = inten[center];
if (val > thresholdMin || val == -Float.MAX_VALUE)
continue;
int x0 = Math.max(0, pt.x - radius);
int y0 = Math.max(0, pt.y - radius);
int x1 = Math.min(intensityImage.width, pt.x + radius + 1);
int y1 = Math.min(intensityImage.height, pt.y + radius + 1);
if (search.searchMin(x0, y0, x1, y1, center, val))
threadCorners.append(pt.x, pt.y);
}
});
// is required inside each thread
for (int i = 0; i < searches.size(); i++) {
found.copyAll(searches.get(i).corners.toList(), (src, dst) -> dst.setTo(src));
}
}
use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class DetectPointsWithNoiseApp method setActiveAlgorithm.
@Override
public synchronized void setActiveAlgorithm(int indexFamily, String name, Object cookie) {
if (input == null)
return;
// corrupt the input image
corruptPanel.corruptImage(grayImage, corruptImage);
final EasyGeneralFeatureDetector<T, D> det = (EasyGeneralFeatureDetector<T, D>) cookie;
det.detect(corruptImage, null);
render.reset();
if (det.getDetector().isDetectMinimums()) {
QueueCorner l = det.getMinimums();
for (int i = 0; i < l.size; i++) {
Point2D_I16 p = l.get(i);
render.addPoint(p.x, p.y, 3, Color.BLUE);
}
}
if (det.getDetector().isDetectMaximums()) {
QueueCorner l = det.getMaximums();
for (int i = 0; i < l.size; i++) {
Point2D_I16 p = l.get(i);
render.addPoint(p.x, p.y, 3, Color.RED);
}
}
SwingUtilities.invokeLater(() -> {
ConvertBufferedImage.convertTo(corruptImage, workImage, true);
Graphics2D g2 = workImage.createGraphics();
g2.setStroke(new BasicStroke(3));
render.draw(g2);
panel.repaint();
});
}
use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class GeneralTemplateMatchTests method checkExpected.
private void checkExpected(boolean strict, Point2D_I32... points) {
// I'm being lazy, update this in the future
assertFalse(alg.isBorderProcessed());
// only process the regions which are not considered the border
int x0 = alg.getBorderX0();
int y0 = alg.getBorderY0();
int x1 = alg.getBorderX1();
int y1 = alg.getBorderY1();
// solutions should be local maximums
NonMaxSuppression extractor;
ConfigExtract config = new ConfigExtract(2, -Float.MAX_VALUE, 0, true);
if (!alg.isMaximize()) {
config.detectMaximums = false;
config.detectMinimums = true;
}
extractor = FactoryFeatureExtractor.nonmax(config);
QueueCorner found = new QueueCorner(10);
GrayF32 intensity = alg.getIntensity().subimage(x0, y0, image.width - x1 + 1, image.height - y1 + 1);
if (alg.isMaximize())
extractor.process(intensity, null, null, null, found);
else
extractor.process(intensity, null, null, found, null);
assertTrue(found.size >= points.length);
// search for all the expected matches
for (Point2D_I32 expected : points) {
int numMatches = 0;
for (Point2D_I16 f : found.toList()) {
if (expected.distance(f.x, f.y) == 0.0)
numMatches++;
}
assertEquals(1, numMatches);
}
if (strict)
assertEquals(points.length, found.size);
}
use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class GeneralFeatureDetector method selectBest.
private void selectBest(GrayF32 intensityImage, QueueCorner found, int numSelect, boolean positive) {
if (numSelect > 0) {
selectBest.setN(numSelect);
selectBest.process(intensityImage, found, positive);
QueueCorner best = selectBest.getBestCorners();
found.reset();
for (int i = 0; i < best.size; i++) {
found.grow().set(best.get(i));
}
}
}
use of boofcv.struct.QueueCorner in project BoofCV by lessthanoptimal.
the class PointTrackerKltPyramid method spawnTracks.
@Override
public void spawnTracks() {
spawned.clear();
// used to convert it from the scale of the bottom layer into the original image
float scaleBottom = (float) basePyramid.getScale(0);
// exclude active tracks
excludeList.reset();
for (int i = 0; i < active.size(); i++) {
PyramidKltFeature f = active.get(i);
excludeList.add((int) (f.x / scaleBottom), (int) (f.y / scaleBottom));
}
// find new tracks, but no more than the max
detector.setExcludeMaximum(excludeList);
detector.process(basePyramid.getLayer(0), derivX[0], derivY[0], null, null, null);
// extract the features
QueueCorner found = detector.getMaximums();
// grow the number of tracks if needed
while (unused.size() < found.size()) addTrackToUnused();
for (int i = 0; i < found.size() && !unused.isEmpty(); i++) {
Point2D_I16 pt = found.get(i);
// set up pyramid description
PyramidKltFeature t = unused.remove(unused.size() - 1);
t.x = pt.x * scaleBottom;
t.y = pt.y * scaleBottom;
tracker.setDescription(t);
// set up point description
PointTrack p = t.getCookie();
p.set(t.x, t.y);
if (checkValidSpawn(p)) {
p.featureId = totalFeatures++;
// add to appropriate lists
active.add(t);
spawned.add(t);
} else {
unused.add(t);
}
}
}
Aggregations