Search in sources :

Example 1 with Polygon2D_I32

use of georegression.struct.shapes.Polygon2D_I32 in project BoofCV by lessthanoptimal.

the class ColorTrackerObjectRectangleTests method setPolygon.

private Polygon2D_I32 setPolygon(Quadrilateral_F64 q) {
    q = q.copy();
    Polygon2D_I32 p = new Polygon2D_I32(4);
    p.vertexes.data[0].set((int) q.a.x, (int) q.a.y);
    p.vertexes.data[1].set((int) q.b.x, (int) q.b.y);
    p.vertexes.data[2].set((int) q.c.x, (int) q.c.y);
    p.vertexes.data[3].set((int) q.d.x, (int) q.d.y);
    return p;
}
Also used : Polygon2D_I32(georegression.struct.shapes.Polygon2D_I32)

Example 2 with Polygon2D_I32

use of georegression.struct.shapes.Polygon2D_I32 in project BoofCV by lessthanoptimal.

the class VideoSequenceSimulator method renderDepth.

public void renderDepth(Se3_F64 worldToCamera, ImageGray depthImage, double units) {
    GImageMiscOps.fill(depthImage, 0);
    for (Square s : squares) {
        Point2D_F64 p1 = PerspectiveOps.renderPixel(worldToCamera, K, s.a);
        Point2D_F64 p2 = PerspectiveOps.renderPixel(worldToCamera, K, s.b);
        Point2D_F64 p3 = PerspectiveOps.renderPixel(worldToCamera, K, s.c);
        Point2D_F64 p4 = PerspectiveOps.renderPixel(worldToCamera, K, s.d);
        if (p1 == null || p2 == null || p3 == null || p4 == null)
            continue;
        Polygon2D_I32 p = new Polygon2D_I32(4);
        p.vertexes.data[0].set((int) p1.x, (int) p1.y);
        p.vertexes.data[1].set((int) p2.x, (int) p2.y);
        p.vertexes.data[2].set((int) p3.x, (int) p3.y);
        p.vertexes.data[3].set((int) p4.x, (int) p4.y);
        int depth = (int) (s.a.z / units);
        convexFill(p, depthImage, depth);
    }
// TODO apply lens distortion
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Polygon2D_I32(georegression.struct.shapes.Polygon2D_I32)

Example 3 with Polygon2D_I32

use of georegression.struct.shapes.Polygon2D_I32 in project BoofCV by lessthanoptimal.

the class VideoSequenceSimulator method render.

public I render(Se3_F64 worldToCamera) {
    GImageMiscOps.fill(outputImage, 0);
    for (Square s : squares) {
        Point2D_F64 p1 = PerspectiveOps.renderPixel(worldToCamera, K, s.a);
        Point2D_F64 p2 = PerspectiveOps.renderPixel(worldToCamera, K, s.b);
        Point2D_F64 p3 = PerspectiveOps.renderPixel(worldToCamera, K, s.c);
        Point2D_F64 p4 = PerspectiveOps.renderPixel(worldToCamera, K, s.d);
        if (p1 == null || p2 == null || p3 == null || p4 == null)
            continue;
        Polygon2D_I32 p = new Polygon2D_I32(4);
        p.vertexes.data[0].set((int) p1.x, (int) p1.y);
        p.vertexes.data[1].set((int) p2.x, (int) p2.y);
        p.vertexes.data[2].set((int) p3.x, (int) p3.y);
        p.vertexes.data[3].set((int) p4.x, (int) p4.y);
        convexFill(p, outputImage, s.gray);
    }
    // TODO apply lens distortion
    return outputImage;
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Polygon2D_I32(georegression.struct.shapes.Polygon2D_I32)

Example 4 with Polygon2D_I32

use of georegression.struct.shapes.Polygon2D_I32 in project BoofCV by lessthanoptimal.

the class TextureGrayTrackerObjectRectangleTests method render.

@Override
protected void render(double scale, double tranX, double tranY) {
    // need to use the same random seed each time
    Random rand = new Random(234);
    for (int i = 0; i < 500; i++) {
        int x = (int) (scale * rand.nextInt(width - 10)) + (int) tranX;
        int y = (int) (scale * rand.nextInt(height - 10)) + (int) tranY;
        int w = (int) (scale * rand.nextInt(100) + 20);
        int h = (int) (scale * rand.nextInt(100) + 20);
        Polygon2D_I32 p = new Polygon2D_I32(4);
        p.vertexes.data[0].set(x, y);
        p.vertexes.data[1].set(x + w, y);
        p.vertexes.data[2].set(x + w, y + h);
        p.vertexes.data[3].set(x, y + h);
        convexFill(p, input, rand.nextInt(255));
    }
}
Also used : Random(java.util.Random) Polygon2D_I32(georegression.struct.shapes.Polygon2D_I32)

Example 5 with Polygon2D_I32

use of georegression.struct.shapes.Polygon2D_I32 in project BoofCV by lessthanoptimal.

the class ColorTrackerObjectRectangleTests method render.

@Override
protected void render(double scale, double tranX, double tranY) {
    // each region in the target region will have a different color.  Allowing scale, translation, and rotation
    // to be estimated using color information alone
    Quadrilateral_F64 q = initRegion.copy();
    // scale it down a bit so that there is a border
    if (multiColor)
        scale(q, 0.95);
    Point2D_F64 ab = average(q.a, q.b);
    Point2D_F64 bc = average(q.b, q.c);
    Point2D_F64 cd = average(q.c, q.d);
    Point2D_F64 da = average(q.d, q.a);
    Point2D_F64 abcd = average(ab, cd);
    Quadrilateral_F64 r0 = new Quadrilateral_F64(q.a, ab, abcd, da, true);
    Quadrilateral_F64 r1 = new Quadrilateral_F64(ab, q.b, bc, abcd, true);
    Quadrilateral_F64 r2 = new Quadrilateral_F64(abcd, bc, q.c, cd, true);
    Quadrilateral_F64 r3 = new Quadrilateral_F64(da, abcd, cd, q.d, true);
    Polygon2D_I32[] region = new Polygon2D_I32[4];
    region[0] = setPolygon(r0);
    region[1] = setPolygon(r1);
    region[2] = setPolygon(r2);
    region[3] = setPolygon(r3);
    int[] band0 = new int[] { 100, 50, 176, 0 };
    int[] band1 = new int[] { 150, 200, 240, 40 };
    int[] band2 = new int[] { 20, 234, 176, 210 };
    GImageMiscOps.fill(original, 0);
    GImageMiscOps.fill(input, 0);
    for (int i = 0; i < 4; i++) {
        int colorIndex;
        if (multiColor)
            colorIndex = i;
        else
            colorIndex = 0;
        TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(0), band0[colorIndex]);
        TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(1), band1[colorIndex]);
        TextureGrayTrackerObjectRectangleTests.convexFill(region[i], original.getBand(2), band2[colorIndex]);
    }
    new FDistort(original, input).affine(scale, 0, 0, scale, tranX, tranY).apply();
}
Also used : FDistort(boofcv.abst.distort.FDistort) Point2D_F64(georegression.struct.point.Point2D_F64) Polygon2D_I32(georegression.struct.shapes.Polygon2D_I32) Quadrilateral_F64(georegression.struct.shapes.Quadrilateral_F64)

Aggregations

Polygon2D_I32 (georegression.struct.shapes.Polygon2D_I32)6 Point2D_F64 (georegression.struct.point.Point2D_F64)3 FDistort (boofcv.abst.distort.FDistort)1 PointIndex_I32 (boofcv.struct.PointIndex_I32)1 Quadrilateral_F64 (georegression.struct.shapes.Quadrilateral_F64)1 Rectangle2D_I32 (georegression.struct.shapes.Rectangle2D_I32)1 Random (java.util.Random)1 Term (nars.term.Term)1