X-Git-Url: http://git.rot13.org/?p=zxing.git;a=blobdiff_plain;f=core%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fcommon%2FGridSampler.java;fp=core%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fcommon%2FGridSampler.java;h=bd892d8896e56bac248de4ec1542390f70aa35da;hp=1a79b9346b7c00367f4d576952ca748b31285fc6;hb=22db33e76ba58134f2dbcfae660267a4062136ac;hpb=37276b87ab934f052aee304396303c276d1c5de5 diff --git a/core/src/com/google/zxing/common/GridSampler.java b/core/src/com/google/zxing/common/GridSampler.java index 1a79b934..bd892d88 100644 --- a/core/src/com/google/zxing/common/GridSampler.java +++ b/core/src/com/google/zxing/common/GridSampler.java @@ -59,30 +59,18 @@ public abstract class GridSampler { } /** - *

Samples an image for a square matrix of bits of the given dimension. This is used to extract - * the black/white modules of a 2D barcode like a QR Code found in an image. Because this barcode - * may be rotated or perspective-distorted, the caller supplies four points in the source image - * that define known points in the barcode, so that the image may be sampled appropriately.

- * - *

The last eight "from" parameters are four X/Y coordinate pairs of locations of points in - * the image that define some significant points in the image to be sample. For example, - * these may be the location of finder pattern in a QR Code.

- * - *

The first eight "to" parameters are four X/Y coordinate pairs measured in the destination - * {@link BitMatrix}, from the top left, where the known points in the image given by the "from" - * parameters map to.

- * - *

These 16 parameters define the transformation needed to sample the image.

- * + * Samples an image for a rectangular matrix of bits of the given dimension. * @param image image to sample - * @param dimension width/height of {@link BitMatrix} to sample from image + * @param dimensionX width of {@link BitMatrix} to sample from image + * @param dimensionY height of {@link BitMatrix} to sample from image * @return {@link BitMatrix} representing a grid of points sampled from the image within a region * defined by the "from" parameters * @throws NotFoundException if image can't be sampled, for example, if the transformation defined * by the given points is invalid or results in sampling outside the image boundaries */ public abstract BitMatrix sampleGrid(BitMatrix image, - int dimension, + int dimensionX, + int dimensionY, float p1ToX, float p1ToY, float p2ToX, float p2ToY, float p3ToX, float p3ToY, @@ -91,35 +79,11 @@ public abstract class GridSampler { float p2FromX, float p2FromY, float p3FromX, float p3FromY, float p4FromX, float p4FromY) throws NotFoundException; - - /** - * Samples an image for a rectangular matrix of bits of the given dimension. - * @param image image to sample - * @param dimensionX width of {@link BitMatrix} to sample from image - * @param dimensionY height of {@link BitMatrix} to sample from image - * @return {@link BitMatrix} representing a grid of points sampled from the image within a region - * defined by the "from" parameters - * @throws NotFoundException if image can't be sampled, for example, if the transformation defined - * by the given points is invalid or results in sampling outside the image boundaries - */ - public abstract BitMatrix sampleGrid(BitMatrix image, - int dimensionX, - int dimensionY, - float p1ToX, float p1ToY, - float p2ToX, float p2ToY, - float p3ToX, float p3ToY, - float p4ToX, float p4ToY, - float p1FromX, float p1FromY, - float p2FromX, float p2FromY, - float p3FromX, float p3FromY, - float p4FromX, float p4FromY) throws NotFoundException; - - public BitMatrix sampleGrid(BitMatrix image, - int dimension, - PerspectiveTransform transform) throws NotFoundException { - throw new IllegalStateException(); // Can't use UnsupportedOperationException - } + public abstract BitMatrix sampleGrid(BitMatrix image, + int dimensionX, + int dimensionY, + PerspectiveTransform transform) throws NotFoundException; /** *

Checks a set of points that have been transformed to sample points on an image against @@ -136,8 +100,7 @@ public abstract class GridSampler { * @param points actual points in x1,y1,...,xn,yn form * @throws NotFoundException if an endpoint is lies outside the image boundaries */ - protected static void checkAndNudgePoints(BitMatrix image, float[] points) - throws NotFoundException { + protected static void checkAndNudgePoints(BitMatrix image, float[] points) throws NotFoundException { int width = image.getWidth(); int height = image.getHeight(); // Check and nudge points from start until we see some that are OK: