You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Compact PDF417 is a PDF417 symbol with no right row indicator column and with the stop pattern reduced to one module bar.
Usually, when PDF417Reader is asked to decode a Compact PDF417 symbol, PDF417ScanningDecoder.merge(...) and PDF417ScanningDecoder.getBarcodeMetadata(...) are eventually asked to merge a correctly-identified left column with a null right column (since the right column doesn't exist), and the decoding moves forward based only on the metadata in the left column.
However, sometimes Detector.findVertices(...) (with help from Detector.findRowsWithPattern(...), Detector.findGuardPattern(...) and Detector.patternMatchVariance(...)) incorrectly identifies the full PDF417 stop pattern within the symbol data, and "finds" the end of the symbol where it doesn't exist. Eventually this creates spurious right column data which makes its way into PDF417ScanningDecoder.getBarcodeMetadata(...), where we realize that we have different information in the left column and the pseudo-right column, and we give up and return a null value which ultimately becomes a NotFoundException.
In the example below, the highlighted section (a pattern of 6 1 1 2 1 1 1 1 1) is mistaken for a stop pattern (a pattern of 7 1 1 3 1 1 1 2 1). Three of the nine counters are off by a full module width each, but the Detector methods mentioned above think it is good enough, based on the very high MAX_INDIVIDUAL_VARIANCE (80%) and MAX_AVG_VARIANCE (42%).
I can imagine a few possible fixes:
reduce the hardcoded variance thresholds (high risk of regressions elsewhere?)
make the variance thresholds configurable (but more knobs make it harder for users to get correct results)
make the compact option explicit, and the compact code path slightly different, rather than implicitly relying on the search for the stop pattern failing (another knob, but a simpler one)
Happy to hear any other ideas!
The sample below encodes +A+CDMEABCDEFGHIJABCDFEFGH in a Compact PDF417 symbol with 12 data column and 74 rows, using ECC level 8.
Sample with incorrect stop pattern highlighted
Sample without any highlighting
The text was updated successfully, but these errors were encountered:
gredler
added a commit
to gredler/zxing
that referenced
this issue
May 23, 2023
A Compact PDF417 is a PDF417 symbol with no right row indicator column and with the stop pattern reduced to one module bar.
Usually, when
PDF417Reader
is asked to decode a Compact PDF417 symbol,PDF417ScanningDecoder.merge(...)
andPDF417ScanningDecoder.getBarcodeMetadata(...)
are eventually asked to merge a correctly-identified left column with anull
right column (since the right column doesn't exist), and the decoding moves forward based only on the metadata in the left column.However, sometimes
Detector.findVertices(...)
(with help fromDetector.findRowsWithPattern(...)
,Detector.findGuardPattern(...)
andDetector.patternMatchVariance(...)
) incorrectly identifies the full PDF417 stop pattern within the symbol data, and "finds" the end of the symbol where it doesn't exist. Eventually this creates spurious right column data which makes its way intoPDF417ScanningDecoder.getBarcodeMetadata(...)
, where we realize that we have different information in the left column and the pseudo-right column, and we give up and return anull
value which ultimately becomes aNotFoundException
.In the example below, the highlighted section (a pattern of 6 1 1 2 1 1 1 1 1) is mistaken for a stop pattern (a pattern of 7 1 1 3 1 1 1 2 1). Three of the nine counters are off by a full module width each, but the
Detector
methods mentioned above think it is good enough, based on the very high MAX_INDIVIDUAL_VARIANCE (80%) and MAX_AVG_VARIANCE (42%).I can imagine a few possible fixes:
Happy to hear any other ideas!
The sample below encodes
+A+CDMEABCDEFGHIJABCDFEFGH
in a Compact PDF417 symbol with 12 data column and 74 rows, using ECC level 8.Sample with incorrect stop pattern highlighted
Sample without any highlighting
The text was updated successfully, but these errors were encountered: