Skip to content

Commit 3a54e5e

Browse files
Fix recursive code detection
1 parent a6957ad commit 3a54e5e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

QuickCode/mobile/src/main/java/com/toolslab/quickcode/model/CodeFileCreator.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,19 @@ private static SparseArray<Barcode> detectCodesScalingDownImageRecursively(@NonN
177177
Logger.logDebug("Trying to detect again with a smaller image," +
178178
" this time " + smallerBitmap.getWidth() + "x" + smallerBitmap.getHeight() +
179179
" instead of " + bitmap.getWidth() + "x" + bitmap.getHeight());
180-
// Before recursive call, get rid of the original bitmap so it doesn't occupy memory
181-
bitmap.recycle();
182-
return detectCodesScalingDownImageRecursively(smallerBitmap, detector);
180+
181+
bitmap.recycle(); // Before recursive call, get rid of the original bitmap so it doesn't occupy memory
182+
183+
Frame frame = new Frame.Builder().setBitmap(smallerBitmap).build();
184+
SparseArray<Barcode> detectedCodes = detector.detect(frame);
185+
if (detectedCodes.size() == 0) {
186+
return detectCodesScalingDownImageRecursively(smallerBitmap, detector);
187+
} else {
188+
return detectedCodes;
189+
}
183190
}
184191
}
192+
// Scaling down is not possible anymore
185193
return null;
186194
}
187195

0 commit comments

Comments
 (0)