Search in sources :

Example 11 with NccFeature

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;
}
Also used : NccFeature(boofcv.struct.feature.NccFeature)

Example 12 with NccFeature

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);
}
Also used : NccFeature(boofcv.struct.feature.NccFeature)

Example 13 with NccFeature

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();
}
Also used : NccFeature(boofcv.struct.feature.NccFeature) BufferedImage(java.awt.image.BufferedImage)

Aggregations

NccFeature (boofcv.struct.feature.NccFeature)13 Test (org.junit.Test)5 DescribePointPixelRegionNCC (boofcv.alg.feature.describe.DescribePointPixelRegionNCC)1 TldRegion (boofcv.alg.tracker.tld.TldRegion)1 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)1 BufferedImage (java.awt.image.BufferedImage)1 ArrayList (java.util.ArrayList)1