dlenski / python-zxing

python wrapper for the ZXing barcode library
GNU Lesser General Public License v3.0
123 stars 37 forks source link

what's the difference between raw and parsed results? #6

Closed Selenium39 closed 3 years ago

Selenium39 commented 4 years ago

i got the result BarCode(raw='This should be QR_CODE', parsed='This should be QR_CODE', format='QR_CODE', type='TEXT', points=[(15.0, 87.0), (15.0, 15.0), (87.0, 15.0), (75.0, 75.0)]), but the row's content the same with the parsed's content. i don't know the difference. could you explain the meanings of the raw and the parsed?give an example is best.

dlenski commented 4 years ago

could you explain the meanings of the raw and the parsed?give an example is best.

It's based entirely on the underlying ZXing Java library, which offers various result parsers to try to understand the structure of the data in barcode text. :man_shrugging:

For example, the GeoResultParser will parse geo: URIs into latitude, longitude, and elevation:

$ qrencode "geo:48.19858,16.37164,171" -o /tmp/test.png

$ zxing /tmp/test.png 
/tmp/test.png
=============
  Decoded GEO barcode in QR_CODE format.
  Raw text:    'geo:48.19858,16.37164,171'
  Parsed text: '48.19858, 16.37164, 171.0m'

For general-purpose barcode parsing, you should use the raw content. Only use the parsed content if you understand and trust how ZXing parses it, and actually want the parsed format.