use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class QrCodeGenerator method renderData.
/**
* Renders the raw data bit output while applying the selected mask
*/
private void renderData() {
QrCodeMaskPattern mask = qr.mask;
int count = 0;
int length = bitLocations.size() - bitLocations.size() % 8;
while (count < length) {
int bits = qr.rawbits[count / 8] & 0xFF;
int N = Math.min(8, bitLocations.size() - count);
for (int i = 0; i < N; i++) {
Point2D_I32 coor = bitLocations.get(count + i);
int value = mask.apply(coor.y, coor.x, ((bits >> i) & 0x01));
// int value = ((bits >> i ) & 0x01);
if (value > 0) {
square(coor.y, coor.x);
}
}
count += 8;
}
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TextureGrayTrackerObjectRectangleTests method convexFill.
public static void convexFill(Polygon2D_I32 poly, GrayU8 image, double value) {
int minX = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE;
int minY = Integer.MAX_VALUE;
int maxY = Integer.MIN_VALUE;
for (int i = 0; i < poly.size(); i++) {
Point2D_I32 p = poly.vertexes.data[i];
if (p.y < minY) {
minY = p.y;
} else if (p.y > maxY) {
maxY = p.y;
}
if (p.x < minX) {
minX = p.x;
} else if (p.x > maxX) {
maxX = p.x;
}
}
ImageRectangle bounds = new ImageRectangle(minX, minY, maxX, maxY);
BoofMiscOps.boundRectangleInside(image, bounds);
Point2D_F64 p = new Point2D_F64();
Polygon2D_F64 poly64 = new Polygon2D_F64(4);
for (int i = 0; i < 4; i++) poly64.vertexes.data[i].set(poly.vertexes.data[i].x, poly.vertexes.data[i].y);
for (int y = bounds.y0; y < bounds.y1; y++) {
p.y = y;
for (int x = bounds.x0; x < bounds.x1; x++) {
p.x = x;
if (Intersection2D_F64.containConvex(poly64, p)) {
GeneralizedImageOps.set(image, x, y, value);
}
}
}
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class ExampleImageStitching method renderStitching.
/**
* Renders and displays the stitched together images
*/
public static void renderStitching(BufferedImage imageA, BufferedImage imageB, Homography2D_F64 fromAtoB) {
// specify size of output image
double scale = 0.5;
// Convert into a BoofCV color format
Planar<GrayF32> colorA = ConvertBufferedImage.convertFromPlanar(imageA, null, true, GrayF32.class);
Planar<GrayF32> colorB = ConvertBufferedImage.convertFromPlanar(imageB, null, true, GrayF32.class);
// Where the output images are rendered into
Planar<GrayF32> work = colorA.createSameShape();
// Adjust the transform so that the whole image can appear inside of it
Homography2D_F64 fromAToWork = new Homography2D_F64(scale, 0, colorA.width / 4, 0, scale, colorA.height / 4, 0, 0, 1);
Homography2D_F64 fromWorkToA = fromAToWork.invert(null);
// Used to render the results onto an image
PixelTransformHomography_F32 model = new PixelTransformHomography_F32();
InterpolatePixelS<GrayF32> interp = FactoryInterpolation.bilinearPixelS(GrayF32.class, BorderType.ZERO);
ImageDistort<Planar<GrayF32>, Planar<GrayF32>> distort = DistortSupport.createDistortPL(GrayF32.class, model, interp, false);
distort.setRenderAll(false);
// Render first image
model.set(fromWorkToA);
distort.apply(colorA, work);
// Render second image
Homography2D_F64 fromWorkToB = fromWorkToA.concat(fromAtoB, null);
model.set(fromWorkToB);
distort.apply(colorB, work);
// Convert the rendered image into a BufferedImage
BufferedImage output = new BufferedImage(work.width, work.height, imageA.getType());
ConvertBufferedImage.convertTo(work, output, true);
Graphics2D g2 = output.createGraphics();
// draw lines around the distorted image to make it easier to see
Homography2D_F64 fromBtoWork = fromWorkToB.invert(null);
Point2D_I32[] corners = new Point2D_I32[4];
corners[0] = renderPoint(0, 0, fromBtoWork);
corners[1] = renderPoint(colorB.width, 0, fromBtoWork);
corners[2] = renderPoint(colorB.width, colorB.height, fromBtoWork);
corners[3] = renderPoint(0, colorB.height, fromBtoWork);
g2.setColor(Color.ORANGE);
g2.setStroke(new BasicStroke(4));
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.drawLine(corners[0].x, corners[0].y, corners[1].x, corners[1].y);
g2.drawLine(corners[1].x, corners[1].y, corners[2].x, corners[2].y);
g2.drawLine(corners[2].x, corners[2].y, corners[3].x, corners[3].y);
g2.drawLine(corners[3].x, corners[3].y, corners[0].x, corners[0].y);
ShowImages.showWindow(output, "Stitched Images", true);
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class ExampleDenseImageFeatures method HighLevel.
// Here's an example of how to use the high level interface. There are a variety of algorithms to choose from
// For much larger images you might need to shrink the image down or change the cell size to get good results.
public static void HighLevel(GrayF32 input) {
System.out.println("\n------------------- Dense High Level");
DescribeImageDense<GrayF32, TupleDesc_F64> describer = FactoryDescribeImageDense.hog(new ConfigDenseHoG(), input.getImageType());
// sift(new ConfigDenseSift(),GrayF32.class);
// surfFast(new ConfigDenseSurfFast(),GrayF32.class);
// process the image and compute the dense image features
describer.process(input);
// print out part of the first few features
System.out.println("Total Features = " + describer.getLocations().size());
for (int i = 0; i < 5; i++) {
Point2D_I32 p = describer.getLocations().get(i);
TupleDesc_F64 d = describer.getDescriptions().get(i);
System.out.printf("%3d %3d = [ %f %f %f %f\n", p.x, p.y, d.value[0], d.value[1], d.value[2], d.value[3]);
// You would process the feature descriptor here
}
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestFitLinesToContour method fitLine.
@Test
public void fitLine() {
FitLinesToContour alg = new FitLinesToContour();
// create the rectangle so that two sizes are less than max samples and the other two more
int w = alg.maxSamples;
alg.contour = createSquare(10, 12, 10 + w - 1, 12 + w + 4);
GrowQueue_I32 corners = createSquareCorners(10, 12, 10 + w - 1, 12 + w + 4);
LineGeneral2D_F64 line = new LineGeneral2D_F64();
for (int i = 0, j = corners.size() - 1; i < corners.size(); j = i, i++) {
alg.fitLine(corners.get(j), corners.get(i), line);
// see if the line lies perfectly along the side
int contour0 = corners.get(j);
int contour1 = corners.get(i);
int length = CircularIndex.distanceP(contour0, contour1, alg.contour.size());
for (int k = 0; k < length; k++) {
int contourIndex = CircularIndex.addOffset(contour0, k, alg.contour.size());
Point2D_I32 p = alg.contour.get(contourIndex);
double found = Distance2D_F64.distance(line, new Point2D_F64(p.x, p.y));
assertEquals(0, found, 1e-8);
}
}
}
Aggregations