Search in sources :

Example 16 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class HoughTransformLineFootOfNorm method extractLines.

/**
 * Searches for local maximas and converts into lines.
 *
 * @return Found lines in the image.
 */
public FastQueue<LineParametric2D_F32> extractLines() {
    lines.reset();
    foundLines.reset();
    foundIntensity.reset();
    extractor.process(transform, null, candidates, null, foundLines);
    for (int i = 0; i < foundLines.size(); i++) {
        Point2D_I16 p = foundLines.get(i);
        int x0 = p.x - originX;
        int y0 = p.y - originY;
        if (Math.abs(x0) >= minDistanceFromOrigin || Math.abs(y0) >= minDistanceFromOrigin) {
            LineParametric2D_F32 l = lines.grow();
            l.p.set(p.x, p.y);
            l.slope.set(-y0, x0);
            foundIntensity.push(transform.get(p.x, p.y));
        }
    }
    return lines;
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) LineParametric2D_F32(georegression.struct.line.LineParametric2D_F32)

Example 17 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class NonMaxCandidate method examineMaximum.

protected void examineMaximum(GrayF32 intensityImage, QueueCorner candidates, QueueCorner found) {
    final int stride = intensityImage.stride;
    final float[] inten = intensityImage.data;
    for (int iter = 0; iter < candidates.size; iter++) {
        Point2D_I16 pt = candidates.data[iter];
        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 < thresholdMax || val == Float.MAX_VALUE)
            continue;
        x0 = Math.max(0, pt.x - radius);
        y0 = Math.max(0, pt.y - radius);
        x1 = Math.min(intensityImage.width, pt.x + radius + 1);
        y1 = Math.min(intensityImage.height, pt.y + radius + 1);
        if (searchMax(center, val))
            found.add(pt.x, pt.y);
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16)

Example 18 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class SelectNBestFeatures method process.

public void process(GrayF32 intensityImage, QueueCorner origCorners, boolean positive) {
    bestCorners.reset();
    if (origCorners.size <= target) {
        // has the desired number, or less
        for (int i = 0; i < origCorners.size; i++) {
            Point2D_I16 pt = origCorners.data[i];
            bestCorners.add(pt.x, pt.y);
        }
    } else {
        // grow internal data structures
        if (origCorners.size > indexes.length) {
            indexes = new int[origCorners.size];
            inten = new float[origCorners.size];
        }
        // extract the intensities for each corner
        Point2D_I16[] points = origCorners.data;
        if (positive) {
            for (int i = 0; i < origCorners.size; i++) {
                Point2D_I16 pt = points[i];
                // quick select selects the k smallest
                // I want the k-biggest so the negative is used
                inten[i] = -intensityImage.get(pt.getX(), pt.getY());
            }
        } else {
            for (int i = 0; i < origCorners.size; i++) {
                Point2D_I16 pt = points[i];
                inten[i] = intensityImage.get(pt.getX(), pt.getY());
            }
        }
        QuickSelect.selectIndex(inten, target, origCorners.size, indexes);
        for (int i = 0; i < target; i++) {
            Point2D_I16 pt = origCorners.data[indexes[i]];
            bestCorners.add(pt.x, pt.y);
        }
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16)

Example 19 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class TemplateMatching method process.

/**
 * Performs template matching.
 */
public void process() {
    // compute match intensities
    if (mask == null)
        match.process(template);
    else
        match.process(template, mask);
    GrayF32 intensity = match.getIntensity();
    int offsetX = 0;
    int offsetY = 0;
    // adjust intensity image size depending on if there is a border or not
    if (!match.isBorderProcessed()) {
        int x0 = match.getBorderX0();
        int x1 = imageWidth - (template.width - x0);
        int y0 = match.getBorderY0();
        int y1 = imageHeight - (template.height - y0);
        intensity = intensity.subimage(x0, y0, x1, y1, null);
    } else {
        offsetX = match.getBorderX0();
        offsetY = match.getBorderY0();
    }
    // find local peaks in intensity image
    candidates.reset();
    extractor.process(intensity, null, null, null, candidates);
    // select the best matches
    if (scores.length < candidates.size) {
        scores = new float[candidates.size];
        indexes = new int[candidates.size];
    }
    for (int i = 0; i < candidates.size; i++) {
        Point2D_I16 p = candidates.get(i);
        scores[i] = -intensity.get(p.x, p.y);
    }
    int N = Math.min(maxMatches, candidates.size);
    QuickSelect.selectIndex(scores, N, candidates.size, indexes);
    // save the results
    results.reset();
    for (int i = 0; i < N; i++) {
        Point2D_I16 p = candidates.get(indexes[i]);
        Match m = results.grow();
        m.score = -scores[indexes[i]];
        m.set(p.x - offsetX, p.y - offsetY);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Point2D_I16(georegression.struct.point.Point2D_I16) Match(boofcv.struct.feature.Match)

Example 20 with Point2D_I16

use of georegression.struct.point.Point2D_I16 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);
        }
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner)

Aggregations

Point2D_I16 (georegression.struct.point.Point2D_I16)27 QueueCorner (boofcv.struct.QueueCorner)12 GrayF32 (boofcv.struct.image.GrayF32)7 ScalePoint (boofcv.struct.feature.ScalePoint)5 ConfigExtract (boofcv.abst.feature.detect.extract.ConfigExtract)3 NonMaxSuppression (boofcv.abst.feature.detect.extract.NonMaxSuppression)3 Test (org.junit.Test)3 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)2 FactoryIntensityPoint (boofcv.factory.feature.detect.intensity.FactoryIntensityPoint)2 FactoryDetectPoint (boofcv.factory.feature.detect.interest.FactoryDetectPoint)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 BufferedImage (java.awt.image.BufferedImage)2 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)1 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)1 DetectorFastNaive (boofcv.alg.feature.detect.intensity.DetectorFastNaive)1 EasyGeneralFeatureDetector (boofcv.alg.feature.detect.interest.EasyGeneralFeatureDetector)1 GeneralFeatureDetector (boofcv.alg.feature.detect.interest.GeneralFeatureDetector)1 OrientationImageAverage (boofcv.alg.feature.orientation.OrientationImageAverage)1