@ericblade/quagga2 1.12.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CYPRESS_UPGRADE_SUMMARY.md +209 -0
- package/DEPENDENCIES.md +31 -8
- package/PLAYWRIGHT_MIGRATION.md +718 -0
- package/README.md +15 -2
- package/dist/quagga.js +328 -165
- package/dist/quagga.min.js +4 -4
- package/docs/reference/configuration.md +63 -0
- package/lib/quagga.js +296 -139
- package/package.json +9 -8
- package/type-definitions/quagga.d.ts +6 -0
|
@@ -644,6 +644,7 @@ Controls the barcode localization algorithm. Only relevant when `locate: true`.
|
|
|
644
644
|
locator: {
|
|
645
645
|
halfSample: true,
|
|
646
646
|
patchSize: "medium",
|
|
647
|
+
thresholding: "global",
|
|
647
648
|
debug: {
|
|
648
649
|
showCanvas: false,
|
|
649
650
|
showPatches: false,
|
|
@@ -734,6 +735,68 @@ locator: {
|
|
|
734
735
|
}
|
|
735
736
|
```
|
|
736
737
|
|
|
738
|
+
### `locator.thresholding` {#locator-thresholding}
|
|
739
|
+
|
|
740
|
+
**Type**: `string`
|
|
741
|
+
|
|
742
|
+
**Options**: `"global"` | `"patch"`
|
|
743
|
+
|
|
744
|
+
**Default**: `"global"`
|
|
745
|
+
|
|
746
|
+
**Description**: How the locator turns the image into black and white before it looks for bar
|
|
747
|
+
patterns.
|
|
748
|
+
|
|
749
|
+
- `"global"`: one Otsu threshold for the whole image.
|
|
750
|
+
- `"patch"`: one Otsu threshold per locator patch, computed from the patch and half a patch around
|
|
751
|
+
it. Patches without contrast are treated as background.
|
|
752
|
+
|
|
753
|
+
A single threshold can fail when large uniform areas make up much of the image, such as a white
|
|
754
|
+
background, a white border, or the empty corners of a rotated photo: they pull the threshold
|
|
755
|
+
above the barcode's light bars, so the barcode turns into one dark area and is not located.
|
|
756
|
+
Consider `"patch"` for such images, and validate it on representative inputs.
|
|
757
|
+
It can also lose correct reads or introduce additional wrong reads; it is not a
|
|
758
|
+
universal replacement for `"global"`. With `decoder.multiple: true`, one image can
|
|
759
|
+
produce both the expected value and an incorrect value.
|
|
760
|
+
|
|
761
|
+
The neighborhood is used only to choose the threshold for the central patch.
|
|
762
|
+
Pixels outside that neighborhood do not contribute to that threshold; they are
|
|
763
|
+
not replaced with white pixels. The contrast check uses that same neighborhood,
|
|
764
|
+
ignores its darkest and lightest 2% of pixels, and requires a gray-level range of
|
|
765
|
+
at least 40. These settings are fixed in this implementation.
|
|
766
|
+
|
|
767
|
+
This option changes only the locator's binary image. The decoder samples the
|
|
768
|
+
grayscale input along lines derived from the located boxes and binarizes those
|
|
769
|
+
lines separately. Different boxes can change both correct and incorrect results
|
|
770
|
+
even though the readers are unchanged.
|
|
771
|
+
|
|
772
|
+
The [thresholding comparison](../examples/locator_thresholding.html) shows the
|
|
773
|
+
binary image, candidate boxes, and decoded values for each mode. Build with
|
|
774
|
+
`npm run build:dev`, serve the repository root, and open
|
|
775
|
+
`docs/examples/locator_thresholding.html`. It uses the development bundle because
|
|
776
|
+
locator debug canvases are unavailable in the production bundle.
|
|
777
|
+
|
|
778
|
+
On the eight white-border fixtures, using Chrome 156, `inputStream.size: 640`,
|
|
779
|
+
`patchSize: "medium"`, the matching UPC or EAN reader, and `multiple: true`:
|
|
780
|
+
|
|
781
|
+
| `halfSample` | Global: expected value found | Patch: expected value found | Global / patch: images with other values |
|
|
782
|
+
|---|---|---|---|
|
|
783
|
+
| `true` | 2/8 | 8/8 | 0/8 / 0/8 |
|
|
784
|
+
| `false` | 2/8 | 4/8 | 0/8 / 1/8 |
|
|
785
|
+
|
|
786
|
+
With half sampling, all five UPC fixtures and `ean-001.jpg` gain the correct
|
|
787
|
+
read; `ean-003.jpg` and `ean-006.jpg` remain correct. Without half sampling,
|
|
788
|
+
patch mode returns `3574660130843` on `ean-001.jpg` instead of the expected
|
|
789
|
+
`3574660239843`, and loses the correct read on `ean-006.jpg`. These fixtures
|
|
790
|
+
illustrate the benefit and limitations; they are not a general accuracy estimate.
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
```javascript
|
|
794
|
+
locator: {
|
|
795
|
+
halfSample: true,
|
|
796
|
+
thresholding: "patch"
|
|
797
|
+
}
|
|
798
|
+
```
|
|
799
|
+
|
|
737
800
|
### `locator.debug` {#locator-debug}
|
|
738
801
|
|
|
739
802
|
**Type**: `object`
|