Search in sources :

Example 6 with PyramidKltFeature

use of boofcv.alg.tracker.klt.PyramidKltFeature in project BoofCV by lessthanoptimal.

the class TestPyramidKltForCombined method setDescription.

@Test
public void setDescription() {
    PyramidKltForCombined<GrayF32, GrayF32> alg = createAlg();
    alg.setInputs(pyramid, derivX, derivY);
    PyramidKltFeature t = alg.createNewTrack();
    alg.setDescription(30.1f, 25, t);
    assertTrue(30.1f == t.x);
    assertTrue(25f == t.y);
    for (int i = 0; i < t.desc.length; i++) {
        double v = ImageStatistics.sum(t.desc[i].desc);
        double dx = ImageStatistics.sum(t.desc[i].derivX);
        double dy = ImageStatistics.sum(t.desc[i].derivY);
        assertTrue(v != 0);
        assertTrue(dx != 0);
        assertTrue(dy != 0);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) PyramidKltFeature(boofcv.alg.tracker.klt.PyramidKltFeature) Test(org.junit.Test)

Example 7 with PyramidKltFeature

use of boofcv.alg.tracker.klt.PyramidKltFeature in project BoofCV by lessthanoptimal.

the class TestPyramidKltForCombined method performTracking.

@Test
public void performTracking() {
    PyramidKltForCombined<GrayF32, GrayF32> alg = createAlg();
    alg.setInputs(pyramid, derivX, derivY);
    PyramidKltFeature t = alg.createNewTrack();
    alg.setDescription(30.1f, 25, t);
    // offset it from the original pose
    t.x = 33.5f;
    t.y = 18f;
    // see if it moves it back close to the original pose
    assertTrue(alg.performTracking(t));
    assertTrue(Math.abs(t.x - 30.1) < 0.1);
    assertTrue(Math.abs(t.y - 25) < 0.1);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) PyramidKltFeature(boofcv.alg.tracker.klt.PyramidKltFeature) Test(org.junit.Test)

Example 8 with PyramidKltFeature

use of boofcv.alg.tracker.klt.PyramidKltFeature in project BoofCV by lessthanoptimal.

the class TldRegionTracker method declareDataStructures.

/**
 * Declares internal data structures based on the input image pyramid
 */
protected void declareDataStructures(PyramidDiscrete<I> image) {
    numPyramidLayers = image.getNumLayers();
    previousDerivX = (D[]) Array.newInstance(derivType, image.getNumLayers());
    previousDerivY = (D[]) Array.newInstance(derivType, image.getNumLayers());
    currentDerivX = (D[]) Array.newInstance(derivType, image.getNumLayers());
    currentDerivY = (D[]) Array.newInstance(derivType, image.getNumLayers());
    for (int i = 0; i < image.getNumLayers(); i++) {
        int w = image.getWidth(i);
        int h = image.getHeight(i);
        previousDerivX[i] = GeneralizedImageOps.createSingleBand(derivType, w, h);
        previousDerivY[i] = GeneralizedImageOps.createSingleBand(derivType, w, h);
        currentDerivX[i] = GeneralizedImageOps.createSingleBand(derivType, w, h);
        currentDerivY[i] = GeneralizedImageOps.createSingleBand(derivType, w, h);
    }
    Class imageClass = image.getImageType().getImageClass();
    previousImage = FactoryPyramid.discreteGaussian(image.getScales(), -1, 1, false, ImageType.single(imageClass));
    previousImage.initialize(image.getInputWidth(), image.getInputHeight());
    for (int i = 0; i < tracks.length; i++) {
        Track t = new Track();
        t.klt = new PyramidKltFeature(numPyramidLayers, featureRadius);
        tracks[i] = t;
    }
}
Also used : PyramidKltFeature(boofcv.alg.tracker.klt.PyramidKltFeature)

Example 9 with PyramidKltFeature

use of boofcv.alg.tracker.klt.PyramidKltFeature in project BoofCV by lessthanoptimal.

the class SparseFlowObjectTracker method declarePyramid.

/**
 * Declares internal data structures
 */
private void declarePyramid(int imageWidth, int imageHeight) {
    int minSize = (config.trackerFeatureRadius * 2 + 1) * 5;
    int[] scales = TldTracker.selectPyramidScale(imageWidth, imageHeight, minSize);
    currentImage = FactoryPyramid.discreteGaussian(scales, -1, 1, false, ImageType.single(imageType));
    currentImage.initialize(imageWidth, imageHeight);
    previousImage = FactoryPyramid.discreteGaussian(scales, -1, 1, false, ImageType.single(imageType));
    previousImage.initialize(imageWidth, imageHeight);
    int numPyramidLayers = currentImage.getNumLayers();
    previousDerivX = (Derivative[]) Array.newInstance(derivType, numPyramidLayers);
    previousDerivY = (Derivative[]) Array.newInstance(derivType, numPyramidLayers);
    currentDerivX = (Derivative[]) Array.newInstance(derivType, numPyramidLayers);
    currentDerivY = (Derivative[]) Array.newInstance(derivType, numPyramidLayers);
    for (int i = 0; i < numPyramidLayers; i++) {
        int w = currentImage.getWidth(i);
        int h = currentImage.getHeight(i);
        previousDerivX[i] = GeneralizedImageOps.createSingleBand(derivType, w, h);
        previousDerivY[i] = GeneralizedImageOps.createSingleBand(derivType, w, h);
        currentDerivX[i] = GeneralizedImageOps.createSingleBand(derivType, w, h);
        currentDerivY[i] = GeneralizedImageOps.createSingleBand(derivType, w, h);
    }
    track = new PyramidKltFeature(numPyramidLayers, config.trackerFeatureRadius);
}
Also used : PyramidKltFeature(boofcv.alg.tracker.klt.PyramidKltFeature)

Aggregations

PyramidKltFeature (boofcv.alg.tracker.klt.PyramidKltFeature)9 KltTrackFault (boofcv.alg.tracker.klt.KltTrackFault)2 GrayF32 (boofcv.struct.image.GrayF32)2 Test (org.junit.Test)2 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)1