Pyzxing解码pdf417代码的原始数据



我正在使用pyzxing来解码图像中的pdf417代码,我现在使用的代码运行良好,并且正在返回pdf417的原始数据,所以我的问题是是否有python模块可以将原始数据解析为人类可读的数据。

我的代码是:

import numpy as np
import cv2
from PIL import Image as PIL
from pdf417decoder import PDF417Decoder
img=PIL.fromarray(img)
reader = BarCodeReader()
results = reader.decode('path to image')
print(results,"n")

结果是:

[{'filename': b'file:/path to image', 'format': b'PDF_417', 'type': b'TEXT', 'raw': b'0357534559x00x00x00x00x00x00x00x00x00x00x00x00x00x00PubDSK_1x00x00x00x00x00x00x00x004x00x00x00x002x8aaxc2xabxc2xb5xc3x8dxc2x8exc2xc2xb8xc2xafRckCXi`VpYkaoxc2xadnxc2x86x08U,x7f_xc2x8axc3x84(xc2x82x11xc2x9dfxc3xbfx007x02Cx00xc2x9f]xc3xbfxc2x80xc2x80uX{xc2xa6|Qrmlxc2x92xc2x88`xc2x97Rwxc2xaadxc2x94kxc2xa9sxc2xb1xc2x8epaxc2x9dcxc2xb1Uxc2x9cIxc2x95Sxc2xa1zuDxc2x9cxc2xafSMxc2x89xc3x8dixc3x88sxc3x95[xc2xb3GMzxc3x9exc2xa1xc2xbdxc2xb1xc2x97xc2x8fxc2xb2xc2xacxc3x9axc2xa1{~xc2xadIxc2xaaxc2x9fxc2x94xc2xb4xc2x83xc2x95xc2x89xc2xa0xc2x92xc2xaexc2x88xc2x9exc2x8emxc2x9f\Yxc2xb8pxc3x87xc2x9bkxc2xa0yxc2xa5nxc3xa0d7xc2xa3xc3x88\xc2x99xc3x93xc3xa6xxc2xbcxc2x88xc3x9bxc2x96xc2xafpxc2x82xc2x8bxc2x90xc2x8e]xc2x85xc2xa5xc3x91xc3x86xc2xbeNi|xc2x9bxc2x89Cxc2x9bQa6xc2x89xc2xb8cNzxc2xa0(6Jxc2x91TYxc2xa4;xc3xbaxc3x9dxc2xb1$xc2xa9xc3x92?xc2xa4xc3xbdx00L)|xc3xaamxc3xb7kxc3x9dxc2xbbxc2x9etxc3xbexc2x96xc2xacxc2x99xc3xacx05<08"xc3x86oxc2xb4xc3x9cxc2x85x0emx13xc3x8dx7fkx11xc3xaaxc3xb90)xc2x8bxc2x86x0c', 'parsed': b'0357534559x00x00x00x00x00x00x00x00x00x00x00x00x00x00PubDSK_1x00x00x00x00x00x00bfxc2x80xc2x80Wxc2x92Nxc2xa0Jxc2x93x~<xc2x87oxc2x81gxc2x84xc2xa1cxc2xb6Uxc2x98[xc2xabPxc2xabzxc2xac>xc2x8aaxc2xabxc2xb5xc3x8dxc2x8exc2xa1Ixc2xa6xc2x9dxc3x85xc2x8exc3x87xc2x9bxc2x93Xx94xc3x86xc2xa5xc2x95xc2xa9~xc2x98xc3x8exc2xa5xc2xa9xc2xb4xc2xbaxc22x8epaxc2x9dcxc2xb1Uxc2x9cIxc2x95Sxc2xa1zuDxc2x9cxc2xafSMxc2x89xc3x8dixc3x88sxc3x95[xc2xb3GMzxc3x9exc2xa1xc2xbdxc2xb1xc2x97xc2x8fxc2xb2xc2xacxc3x9axc2xa1{~xc2xadIxc2xaaxc2x9fxc2x94xc2xb4xc2x83xc2x95xc2x89xc2xa0xc2x92xc2xaexc2x88xc2x9exc2x8emxc2x9f\Yxc2xb8pxc3x87xc2x9bkxc2xa0yxc2xa5nxc3xa0d7xc2xa3xc3x88\xc2x99xc3x93xc3xa6xxc2xbcxc2x88xc3x9bxc2x96xc2xafpxc2x82xc2x8bxc2x90xc2x8e]xc2x85xc2xa5xc3x91xc3x86xc2xbeNi|xc2x9bxc2x89Cxc2x9bQa6xc2x89xc2xb8cNzxc2xa0(6Jxc2x91TYxc2xa4;xc3xbaxc3x9dxc2xb1$xc2xa9xc3x92?xc2xa4xc3xbdx00L)|xc3xaamxc3xb7kxc3x9dxc2xbbxc2x9etxc3xbexc2x96xc2xacxc2x99xc3xacx05<08"xc3x86oxc2xb4xc3x9cxc2x85x0emx13xc3x8dx7fkx11xc3xaaxc3xb90)xc2x8bxc2x86x0c', 'points': [(316.0, 1475.0), (324.0, 2017.0), (3488.0, 1463.0), (3475.0, 1998.0), (441.0, 1475.0), (450.0, 2017.0), (3366.0, 1463.0), (3353.0, 1998.0)]}] 

我损坏了原始数据,因为它是个人身份证,但它似乎是好的。

如输出中所示,被识别为pdf417代码。

您将获得一个字典列表。因此,浏览字典(即使在这种情况下只有一个),然后解码"raw"的值,该值似乎编码在utf-16:中

for res in results:
print(res['raw'].decode('utf-16'))

如果结果看起来不像预期的那样,请尝试其他编码。

编辑:有关可用编码的列表,请参见Python文档。例如,如果语言是泰语,ISO-8859-11可能会提供更好的输出:

for res in results:
print(res['raw'].decode('ISO-8859-11'))

相关内容

  • 没有找到相关文章

最新更新