From bd2521cb8ef74f2ed566c2ca6643c5ffccdf30af Mon Sep 17 00:00:00 2001 From: magethle Date: Mon, 10 Feb 2025 15:01:44 +0100 Subject: [PATCH] Add comment to distortion calculation The formula for calculating the distortion seems wrong but practically it seems to work slightly better --- .../com/google/zxing/qrcode/detector/FinderPatternFinder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/com/google/zxing/qrcode/detector/FinderPatternFinder.java b/core/src/main/java/com/google/zxing/qrcode/detector/FinderPatternFinder.java index 17ca88b8f..951bd197f 100755 --- a/core/src/main/java/com/google/zxing/qrcode/detector/FinderPatternFinder.java +++ b/core/src/main/java/com/google/zxing/qrcode/detector/FinderPatternFinder.java @@ -695,6 +695,8 @@ public class FinderPatternFinder { // we need to check both two equal sides separately. // The value of |c^2 - 2 * b^2| + |c^2 - 2 * a^2| increases as dissimilarity // from isosceles right triangle. + // Heuristically it seems that the following formula works better (although it's + // not clear any more why...) double d = Math.abs(c - 2 * b) + Math.abs(c - 2 * a); if (d < distortion) { distortion = d;