Search in sources :

Example 36 with Point2D_I32

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

the class VisualizeHogDescriptorApp method selectRegion.

private void selectRegion(int x, int y) {
    int bestIndex = -1;
    synchronized (hogLock) {
        double bestDistance = Double.MAX_VALUE;
        List<Point2D_I32> locations = hog.getLocations();
        for (int i = 0; i < locations.size(); i++) {
            Point2D_I32 p = locations.get(i);
            double d = UtilPoint2D_I32.distance(p.x, p.y, x, y);
            if (d < bestDistance) {
                bestDistance = d;
                bestIndex = i;
            }
        }
        if (bestIndex >= 0) {
            selectedPixel = new Point2D_I32(x, y);
            selectedIndex = bestIndex;
            targetDesc = hog.getDescriptions().get(bestIndex);
            targetLocation = hog.getLocations().get(bestIndex);
            imagePanel.repaint();
        }
    }
}
Also used : UtilPoint2D_I32(georegression.geometry.UtilPoint2D_I32) Point2D_I32(georegression.struct.point.Point2D_I32)

Example 37 with Point2D_I32

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

the class VisualizeImageData method drawEdgeContours.

/**
 * Draws each contour using a unique color.  Each segment of each edge is drawn using the same colors.
 *
 * @param contours List of edge contours
 * @param colors RGB color for each edge
 * @param output Where the output is written to
 * @param storage Optional working buffer for Bitmap image. Can be null.
 */
public static void drawEdgeContours(List<EdgeContour> contours, int[] colors, Bitmap output, byte[] storage) {
    if (output.getConfig() != Bitmap.Config.ARGB_8888)
        throw new IllegalArgumentException("Only ARGB_8888 is supported");
    if (storage == null)
        storage = declareStorage(output, null);
    else
        Arrays.fill(storage, (byte) 0);
    for (int i = 0; i < contours.size(); i++) {
        EdgeContour e = contours.get(i);
        int c = colors[i];
        for (int j = 0; j < e.segments.size(); j++) {
            EdgeSegment s = e.segments.get(j);
            for (int k = 0; k < s.points.size(); k++) {
                Point2D_I32 p = s.points.get(k);
                int index = p.y * 4 * output.getWidth() + p.x * 4;
                storage[index++] = (byte) (c >> 16);
                storage[index++] = (byte) (c >> 8);
                storage[index++] = (byte) c;
                storage[index] = (byte) 0xFF;
            }
        }
    }
    output.copyPixelsFromBuffer(ByteBuffer.wrap(storage));
}
Also used : EdgeSegment(boofcv.alg.feature.detect.edge.EdgeSegment) Point2D_I32(georegression.struct.point.Point2D_I32) EdgeContour(boofcv.alg.feature.detect.edge.EdgeContour)

Example 38 with Point2D_I32

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

the class DescribeImageDenseHoG method process.

@Override
public void process(T input) {
    hog.setInput(input);
    hog.process();
    // center region locations to make it compliant with this interface
    FastQueue<Point2D_I32> locations = hog.getLocations();
    int rx = hog.getRegionWidthPixelX() / 2;
    int ry = hog.getRegionWidthPixelY() / 2;
    for (int i = 0; i < locations.size(); i++) {
        Point2D_I32 p = locations.get(i);
        p.x += rx;
        p.y += ry;
    }
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32)

Example 39 with Point2D_I32

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

the class GeneralTemplateMatchTests method multipleCases.

/**
 * Provide two matches
 */
@Test
public void multipleCases() {
    GImageMiscOps.fillUniform(image, rand, 0, 200);
    Point2D_I32 a = new Point2D_I32(10, 12);
    Point2D_I32 b = new Point2D_I32(20, 16);
    setTemplate(a.x, a.y);
    setTemplate(b.x, b.y);
    alg.setInputImage(image);
    alg.process(template);
    checkExpected(a, b);
    // uniform mask should produce identical results
    GImageMiscOps.fill(mask, 1);
    alg.process(template, mask);
    checkExpected(a, b);
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Example 40 with Point2D_I32

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

the class QrCodeEncoder method scoreMask.

private static double scoreMask(int N, List<Point2D_I32> locations, PackedBits8 bits, QrCodeCodeWordLocations matrix, QrCodeMaskPattern mask) {
    FoundFeatures features = new FoundFeatures();
    // write the bits plus mask into the matrix
    int blackInBlock = 0;
    for (int i = 0; i < bits.size; i++) {
        Point2D_I32 p = locations.get(i);
        boolean v = mask.apply(p.y, p.x, bits.get(i)) == 1;
        matrix.unsafe_set(p.y, p.x, v);
        if (v) {
            blackInBlock++;
        }
        if ((i + 1) % 8 == 0) {
            if (blackInBlock == 0 || blackInBlock == 8) {
                features.sameColorBlock++;
            }
            blackInBlock = 0;
        }
    }
    // look for adjacent blocks that are the same color as well as patterns that
    // could be confused for position patterns 1,1,3,1,1
    // in vertical and horizontal directions
    detectAdjacentAndPositionPatterns(N, matrix, features);
    // penalize it if it's heavily skewed towards one color
    // this is a more significant deviation
    double scale = matrix.sum() / (double) (N * N);
    scale = scale < 0.5 ? 0.5 - scale : scale - 0.5;
    // System.out.println("adjacent "+features.adjacent+"  block "+features.sameColorBlock+" "+features.position+"  s "+(N*N*scale));
    return features.adjacent + 3 * features.sameColorBlock + 40 * features.position + N * N * scale;
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32)

Aggregations

Point2D_I32 (georegression.struct.point.Point2D_I32)153 Test (org.junit.Test)64 ArrayList (java.util.ArrayList)41 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)21 Point2D_F64 (georegression.struct.point.Point2D_F64)11 EdgeContour (boofcv.alg.feature.detect.edge.EdgeContour)8 GrayF32 (boofcv.struct.image.GrayF32)8 GrayS32 (boofcv.struct.image.GrayS32)7 Contour (boofcv.alg.filter.binary.Contour)6 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)6 GrayU8 (boofcv.struct.image.GrayU8)6 PackedSetsPoint2D_I32 (boofcv.struct.PackedSetsPoint2D_I32)5 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)5 UtilPoint2D_I32 (georegression.geometry.UtilPoint2D_I32)4 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)4 EdgeSegment (boofcv.alg.feature.detect.edge.EdgeSegment)3 Corner (boofcv.alg.shapes.polyline.splitmerge.PolylineSplitMerge.Corner)3 FactoryDescribeImageDense (boofcv.factory.feature.dense.FactoryDescribeImageDense)3 PointIndex_I32 (boofcv.struct.PointIndex_I32)3 LineGeneral2D_F64 (georegression.struct.line.LineGeneral2D_F64)3