Commit a08836e
committed
feat(vendor/kik/scanner): improve kik code detection robustness and performance
This commit introduces signficant improvements to the native c++ scanning library to enhance detection accuracy and speed,
addressing issues where scanning only worked when zoomed in or was slow to initialize.
The key changes are:
1. **Replaced Global with Adaptive Thresholding**
- The core `detectKikCode` algorithm has been updated to use `cv::adaptiveThreshold` instead of a fixed, global `cv::threshold`.
- This makes the binarization step far more resilient to variations in lighting, such as shadows and glare. It directly addresses the problem
where users had to zoom in to create a high-contrast image for the scanner to work.
- The new method creates both standard and inverted binary images (`whitish` and `blackish`) efficiently, which are required for finding both light-on-dark and dark-on-light codes.
2. **Optimized JNI Memory Handling**
- The call to `ReleaseByteArrayElements` has been modified to use the `JNI_ABORT` flag instead of `0`.
- Since the image data from the Java layer is only read from and never modified in the native code, this flag tells the JVM it can release the memory without performing
an unnecessary and costly copy-back operation.
- This reduces per-frame processing overhead, contributing to a faster and more responsive scanning experience.
3. **Set scan quality to Best**
- Now that we are Android 10/Q+, we can safely place the default as BEST, over the previous default of Medium.
These changes work together to make the scanner more reliable across a wider range of devices and environmental conditions.
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>1 parent d3de756 commit a08836e
3 files changed
Lines changed: 28 additions & 2 deletions
File tree
- vendor/kik/scanner/src/main
- cpp/scan
- kotlin/com/kik/kikx/kikcodes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
420 | 437 | | |
421 | 438 | | |
422 | 439 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
| |||
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | | - | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
0 commit comments