use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.
the class TestScoreAssociateNccFeature method createDescription.
@Override
public NccFeature createDescription() {
NccFeature a = new NccFeature(5);
a.mean = 10;
a.sigma = 5;
for (int i = 0; i < a.size(); i++) a.value[i] = rand.nextGaussian() * 2;
return a;
}
use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.
the class TldTemplateMatching method addDescriptor.
public void addDescriptor(boolean positive, float x0, float y0, float x1, float y1) {
NccFeature f = createDescriptor();
computeNccDescriptor(f, x0, y0, x1, y1);
addDescriptor(positive, f);
}
use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.
the class TldTemplatePanel method update.
public synchronized void update(List<NccFeature> features, boolean gray) {
unused.addAll(templates);
templates.clear();
for (NccFeature f : features) {
BufferedImage img;
if (unused.isEmpty()) {
img = new BufferedImage(featureWidth, featureWidth, BufferedImage.TYPE_INT_RGB);
} else {
img = unused.pop();
}
templates.add(img);
int index = 0;
int rgb;
if (gray) {
for (int y = 0; y < featureWidth; y++) {
for (int x = 0; x < featureWidth; x++) {
int v = (int) (f.value[index++] + f.mean);
rgb = v << 16 | v << 8 | v;
img.setRGB(x, y, rgb);
}
}
} else {
double maxAbs = 0;
for (int i = 0; i < f.value.length; i++) {
double v = Math.abs(f.value[i]);
if (v > maxAbs)
maxAbs = v;
}
if (maxAbs == 0)
continue;
for (int y = 0; y < featureWidth; y++) {
for (int x = 0; x < featureWidth; x++) {
int v = (int) (255.0 * f.value[index++] / maxAbs);
if (v < 0)
rgb = -v;
else
rgb = v << 16;
img.setRGB(x, y, rgb);
}
}
}
}
setPreferredSize(new Dimension(featureWidth * scale, featureWidth * features.size() * scale));
setMinimumSize(getPreferredSize());
revalidate();
}
Aggregations