use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestQrCodeCodeWordLocations method printCodeWords.
void printCodeWords(QrCodeCodeWordLocations alg) {
int N = alg.numRows;
char[][] m = new char[N][N];
for (int i = 0; i < alg.bits.size(); i++) {
Point2D_I32 c = alg.bits.get(i);
m[c.y][c.x] = (char) ((i / 8) + 48);
}
System.out.println("Shape " + N + " " + N);
for (int row = 0; row < N; row++) {
for (int col = 0; col < N; col++) {
if (m[row][col] == 0)
if (alg.get(row, col))
System.out.print("-");
else
System.out.print("_");
else
System.out.print("" + m[row][col]);
}
System.out.println();
}
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class SubpixelGridTargetDisplay method paintComponent.
@Override
public synchronized void paintComponent(Graphics g) {
super.paintComponent(g);
if (input == null) {
return;
}
Graphics2D g2 = (Graphics2D) g;
Rectangle r = getVisibleRect();
render(r);
g2.drawImage(workImage, r.x, r.y, null);
if (showCrude && crudePoints != null) {
for (Point2D_I32 p : crudePoints) {
// put it in the center of a pixel
int x = (int) Math.round(p.x * scale + 0.5 * scale);
int y = (int) Math.round(p.y * scale + 0.5 * scale);
VisualizeFeatures.drawPoint(g2, x, y, Color.GRAY);
}
}
if (showRefined && refinedPoints != null) {
for (Point2D_F64 p : refinedPoints) {
// put it in the center of a pixel
int x = (int) Math.round(p.x * scale + 0.5 * scale);
int y = (int) Math.round(p.y * scale + 0.5 * scale);
VisualizeFeatures.drawPoint(g2, x, y, Color.RED);
}
}
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class VisualizeImageData method drawEdgeContours.
/**
* Draws each contour using a single color.
*
* @param contours List of edge contours
* @param color The RGB color that each edge pixel should be drawn
* @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 color, 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);
byte r = (byte) ((color >> 16) & 0xFF);
byte g = (byte) ((color >> 8) & 0xFF);
byte b = (byte) (color);
for (int i = 0; i < contours.size(); i++) {
EdgeContour e = contours.get(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++] = b;
storage[index++] = g;
storage[index++] = r;
storage[index] = (byte) 0xFF;
}
}
}
output.copyPixelsFromBuffer(ByteBuffer.wrap(storage));
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestDescribeImageDenseHoG method check.
private void check(ConfigDenseHoG config) {
int offX = config.pixelsPerCell * config.cellsPerBlockX / 2;
int offY = config.pixelsPerCell * config.cellsPerBlockY / 2;
int stride = config.pixelsPerCell * config.stepBlock;
for (ImageType type : imageTypes) {
ImageBase image = type.createImage(width, height);
GImageMiscOps.fillUniform(image, rand, 0, 200);
DescribeImageDense alg = createAlg(type, config);
alg.process(image);
List<Point2D_I32> locations = alg.getLocations();
assertTrue(locations.size() > 0);
assertEquals(locations.size(), alg.getDescriptions().size());
for (int i = 0; i < locations.size(); i++) {
Point2D_I32 p = locations.get(i);
// see if the feature lies on a grid that's at the descriptor region's center
assertEquals(0, (p.x - offX) % stride);
assertEquals(0, (p.y - offY) % stride);
}
}
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestGenericDenseDescribeImage method process.
/**
* Give it a known situation and see if it produces the expected results
*/
@Test
public void process() {
DummyFeature sparse = new DummyFeature();
GenericDenseDescribeImageDense alg = new GenericDenseDescribeImageDense(sparse, 1, 1.5, 3, 4);
GrayU8 image = new GrayU8(100, 110);
alg.process(image);
List<TupleDesc_F64> descs = alg.getDescriptions();
List<Point2D_I32> points = alg.getLocations();
assertEquals(descs.size(), points.size());
int featureRadius = (int) Math.round(1.5 * 7.0 / 2.0);
int w = (100 - 2 * featureRadius) / 3;
int h = (110 - 2 * featureRadius) / 4;
// -1 since it intentionally skips feature 20
assertEquals(w * h - 1, points.size());
int count = 0;
for (int y = 0; y < h; y++) {
int pixelY = featureRadius + y * y;
for (int x = 0; x < w; x++) {
int pixelX = featureRadius + x * 3;
Point2D_I32 p = null;
if (count < 19) {
p = points.get(count);
} else if (count > 20) {
p = points.get(count + 1);
} else {
continue;
}
assertEquals("count = " + count, pixelX, p.x);
assertEquals(pixelY, p.y);
count++;
}
}
}
Aggregations