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();
}
}
}
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));
}
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;
}
}
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);
}
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;
}
Aggregations