use of org.ddogleg.struct.FastArray in project BoofCV by lessthanoptimal.
the class TestFeatureSelectUniformBest method checkAllCells.
private void checkAllCells(boolean positive) {
float largeValue = positive ? 5 : -5;
// every pixel is a corner
QueueCorner detected = new QueueCorner();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
detected.grow().setTo(x, y);
}
}
int cellSize = 10;
for (int y = 0; y < height; y += cellSize) {
for (int x = 0; x < width; x += cellSize) {
intensity.set(x + 2, y + 2, largeValue);
}
}
// this one corner will by far have the most intense features
for (int y = 0; y < cellSize; y++) {
for (int x = 0; x < cellSize; x++) {
intensity.set(x, y, intensity.get(x, y) + largeValue * 4);
}
}
var found = new FastArray<>(Point2D_I16.class);
FeatureSelectUniformBest<Point2D_I16> alg = createAlgorithm();
// make it easy to know the cell size
alg.configUniform = new HackedConfig(cellSize);
// it should spread out the detections evenly throughout the cells
checkSpread(positive, detected, cellSize, 1, found, alg);
// The ones it selects should be the ones with the large values
for (int y = 0; y < height; y += cellSize) {
for (int x = 0; x < width; x += cellSize) {
checkInside(x + 2, y + 2, found);
}
}
checkSpread(positive, detected, cellSize, 2, found, alg);
// The ones it selects should be the ones with the large values
for (int y = 0; y < height; y += cellSize) {
for (int x = 0; x < width; x += cellSize) {
checkInside(x + 2, y + 2, found);
}
}
}
use of org.ddogleg.struct.FastArray in project BoofCV by lessthanoptimal.
the class HierarchicalVocabularyTree method traverseGraphDepthFirst.
/**
* Traverses every node in the graph (excluding the root) in a depth first manor.
*
* @param op Every node is feed into this function
*/
public void traverseGraphDepthFirst(BoofLambdas.ProcessObject<Node> op) {
FastArray<Node> queue = new FastArray<>(Node.class, maximumLevel);
queue.add(nodes.get(0));
DogArray_I32 branches = new DogArray_I32(maximumLevel);
branches.add(0);
if (nodes.get(0).isLeaf())
return;
while (!queue.isEmpty()) {
Node n = queue.getTail();
int branch = branches.getTail();
// If there are no more children to traverse in this node go back to the parent
if (branch >= n.childrenIndexes.size) {
queue.removeTail();
branches.removeTail();
continue;
}
// next iteration will explore the next branch
branches.setTail(0, branch + 1);
// Pass in the child
n = nodes.get(n.childrenIndexes.get(branch));
op.process(n);
// Can't dive into any children/branches if it's a leaf
if (n.isLeaf())
continue;
queue.add(n);
branches.add(0);
}
}
Aggregations