X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=core%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fdatamatrix%2Fdetector%2FDetector.java;h=30fb437fc88f596c58db316ba146c10c4bdf0833;hb=a6f2683ccc234dd3a70b2758f31e86d3fa810279;hp=3cd2c1da00824e59cb9ee706e230c87d991a6463;hpb=f5f458fc312e35c7e18280fd06d0b7e809749908;p=zxing.git diff --git a/core/src/com/google/zxing/datamatrix/detector/Detector.java b/core/src/com/google/zxing/datamatrix/detector/Detector.java index 3cd2c1da..30fb437f 100644 --- a/core/src/com/google/zxing/datamatrix/detector/Detector.java +++ b/core/src/com/google/zxing/datamatrix/detector/Detector.java @@ -143,16 +143,11 @@ public final class Detector { // The top right point is actually the corner of a module, which is one of the two black modules // adjacent to the white module at the top right. Tracing to that corner from either the top left - // or bottom right should work here, but, one will be more reliable since it's traced straight - // up or across, rather than at a slight angle. We use dot products to figure out which is - // better to use: - int dimension; - if (GenericResultPoint.crossProductZ(bottomLeft, bottomRight, topRight) < - GenericResultPoint.crossProductZ(topRight, topLeft, bottomLeft)) { - dimension = transitionsBetween(topLeft, topRight).getTransitions(); - } else { - dimension = transitionsBetween(bottomRight, topRight).getTransitions(); - } + // or bottom right should work here. The number of transitions could be higher than it should be + // due to noise. So we try both and take the min. + + int dimension = Math.min(transitionsBetween(topLeft, topRight).getTransitions(), + transitionsBetween(bottomRight, topRight).getTransitions()); dimension += 2; BitMatrix bits = sampleGrid(image, topLeft, bottomLeft, bottomRight, dimension);