private static BitMatrix sampleGrid(BitMatrix image, ResultPoint topLeft, ResultPoint bottomLeft, ResultPoint bottomRight, ResultPoint topRight, int dimensionX, int dimensionY) { GridSampler sampler = GridSampler.Instance; return(sampler.sampleGrid(image, dimensionX, dimensionY, 0.5f, 0.5f, dimensionX - 0.5f, 0.5f, dimensionX - 0.5f, dimensionY - 0.5f, 0.5f, dimensionY - 0.5f, topLeft.X, topLeft.Y, topRight.X, topRight.Y, bottomRight.X, bottomRight.Y, bottomLeft.X, bottomLeft.Y)); }
private static BitMatrix sampleGrid(BitMatrix matrix, ResultPoint topLeft, ResultPoint bottomLeft, ResultPoint topRight, ResultPoint bottomRight, int xdimension, int ydimension) { // Note that unlike the QR Code sampler, we didn't find the center of modules, but the // very corners. So there is no 0.5f here; 0.0f is right. GridSampler sampler = GridSampler.Instance; return(sampler.sampleGrid( matrix, xdimension, ydimension, 0.0f, // p1ToX 0.0f, // p1ToY xdimension, // p2ToX 0.0f, // p2ToY xdimension, // p3ToX ydimension, // p3ToY 0.0f, // p4ToX ydimension, // p4ToY topLeft.X, // p1FromX topLeft.Y, // p1FromY topRight.X, // p2FromX topRight.Y, // p2FromY bottomRight.X, // p3FromX bottomRight.Y, // p3FromY bottomLeft.X, // p4FromX bottomLeft.Y)); // p4FromY }
private static BitMatrix sampleGrid(MonochromeBitmapSource image, ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft, ResultPoint alignmentPattern, int dimension) { float dimMinusThree = (float)dimension - 3.5f; float bottomRightX; float bottomRightY; float sourceBottomRightX; float sourceBottomRightY; if (alignmentPattern != null) { bottomRightX = alignmentPattern.getX(); bottomRightY = alignmentPattern.getY(); sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f; } else { // Don't have an alignment pattern, just make up the bottom-right point bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX(); bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY(); sourceBottomRightX = sourceBottomRightY = dimMinusThree; } GridSampler sampler = GridSampler.Instance; return(sampler.sampleGrid( image, dimension, 3.5f, 3.5f, dimMinusThree, 3.5f, sourceBottomRightX, sourceBottomRightY, 3.5f, dimMinusThree, topLeft.getX(), topLeft.getY(), topRight.getX(), topRight.getY(), bottomRightX, bottomRightY, bottomLeft.getX(), bottomLeft.getY())); }
/// <summary> /// Samples an Aztec matrix from an image /// </summary> /// <param name="image">The image.</param> /// <param name="topLeft">The top left.</param> /// <param name="bottomLeft">The bottom left.</param> /// <param name="bottomRight">The bottom right.</param> /// <param name="topRight">The top right.</param> /// <returns></returns> private BitMatrix sampleGrid(BitMatrix image, ResultPoint topLeft, ResultPoint bottomLeft, ResultPoint bottomRight, ResultPoint topRight) { int dimension; if (compact) { dimension = 4 * nbLayers + 11; } else { if (nbLayers <= 4) { dimension = 4 * nbLayers + 15; } else { dimension = 4 * nbLayers + 2 * ((nbLayers - 4) / 8 + 1) + 15; } } GridSampler sampler = GridSampler.Instance; return(sampler.sampleGrid(image, dimension, dimension, 0.5f, 0.5f, dimension - 0.5f, 0.5f, dimension - 0.5f, dimension - 0.5f, 0.5f, dimension - 0.5f, topLeft.X, topLeft.Y, topRight.X, topRight.Y, bottomRight.X, bottomRight.Y, bottomLeft.X, bottomLeft.Y)); }
private static BitMatrix sampleGrid(MonochromeBitmapSource image, ResultPoint topLeft, ResultPoint bottomLeft, ResultPoint bottomRight, int dimension) { // We make up the top right point for now, based on the others. // TODO: we actually found a fourth corner above and figured out which of two modules // it was the corner of. We could use that here and adjust for perspective distortion. float topRightX = (bottomRight.getX() - bottomLeft.getX()) + topLeft.getX(); float topRightY = (bottomRight.getY() - bottomLeft.getY()) + topLeft.getY(); // Note that unlike in the QR Code sampler, we didn't find the center of modules, but the // very corners. So there is no 0.5f here; 0.0f is right. GridSampler sampler = GridSampler.Instance; return(sampler.sampleGrid( image, dimension, 0.0f, 0.0f, dimension, 0.0f, dimension, dimension, 0.0f, dimension, topLeft.getX(), topLeft.getY(), topRightX, topRightY, bottomRight.getX(), bottomRight.getY(), bottomLeft.getX(), bottomLeft.getY())); }
/// <summary> /// Creates a BitMatrix by sampling the provided image. /// topLeft, topRight, bottomRight, and bottomLeft are the centers of the squares on the /// diagonal just outside the bull's eye. /// </summary> /// <param name="image">The image.</param> /// <param name="topLeft">The top left.</param> /// <param name="bottomLeft">The bottom left.</param> /// <param name="bottomRight">The bottom right.</param> /// <param name="topRight">The top right.</param> /// <returns></returns> private BitMatrix sampleGrid(BitMatrix image, ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomRight, ResultPoint bottomLeft) { GridSampler sampler = GridSampler.Instance; int dimension = getDimension(); float low = dimension / 2.0f - nbCenterLayers; float high = dimension / 2.0f + nbCenterLayers; return(sampler.sampleGrid(image, dimension, dimension, low, low, // topleft high, low, // topright high, high, // bottomright low, high, // bottomleft topLeft.X, topLeft.Y, topRight.X, topRight.Y, bottomRight.X, bottomRight.Y, bottomLeft.X, bottomLeft.Y)); }
private static BitMatrix sampleGrid(BitMatrix image, PerspectiveTransform transform, int dimension) { GridSampler sampler = GridSampler.Instance; return(sampler.sampleGrid(image, dimension, dimension, transform)); }