微慑信息网

python 二维码识别の qrcode | opencv |zxing

之前识别二维码使用pyzbar,参考:

通过python判断图片是否包含二维码 : vulsee.com

今天在清理二维码文件时,发现有二维码无法识别:

使用qrcode:

 

def decode_qr_code(code_img_path):
    if not os.path.exists(code_img_path):
        raise FileExistsError(code_img_path)
    # Here, set only recognize QR Code and ignore other type of code
    return pyzbar.decode(Image.open(code_img_path), symbols=[pyzbar.ZBarSymbol.QRCODE])

依然无法识别。

使用opencv-python

 

安装:在python27下,直接

pip install opencv_python

报错:

Collecting opencv-python
Using cached opencv-python-4.3.0.38.tar.gz (88.0 MB)
Installing build dependencies … done
Getting requirements to build wheel … error
ERROR: Command errored out with exit status 1:
command: ‘c:\python27\python.exe’ ‘c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py’ get_requires_for_build_wheel ‘c:\users\***\appdata\local\temp\tmpsa5iv2’
cwd: c:\users\***\appdata\local\temp\pip-install-_ieppp\opencv-python
Complete output (22 lines):
Traceback (most recent call last):
File “c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py”, line 280, in <module>
main()
File “c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py”, line 263, in main
json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
File “c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py”, line 114, in get_requires_for_build_wheel
return hook(config_settings)
File “c:\users\***\appdata\local\temp\pip-build-env-hezrts\overlay\Lib\site-packages\setuptools\build_meta.py”, line 146, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[‘wheel’])
File “c:\users\***\appdata\local\temp\pip-build-env-hezrts\overlay\Lib\site-packages\setuptools\build_meta.py”, line 127, in _get_build_requires
self.run_setup()
File “c:\users\***\appdata\local\temp\pip-build-env-hezrts\overlay\Lib\site-packages\setuptools\build_meta.py”, line 243, in run_setup
self).run_setup(setup_script=setup_script)
File “c:\users\***\appdata\local\temp\pip-build-env-hezrts\overlay\Lib\site-packages\setuptools\build_meta.py”, line 142, in run_setup
exec(compile(code, __file__, ‘exec’), locals())
File “setup.py”, line 448, in <module>
main()
File “setup.py”, line 99, in main
% {“ext”: re.escape(sysconfig.get_config_var(“EXT_SUFFIX”))}
File “c:\python27\lib\re.py”, line 210, in escape
s = list(pattern)
TypeError: ‘NoneType’ object is not iterable
—————————————-
ERROR: Command errored out with exit status 1: ‘c:\python27\python.exe’ ‘c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py’ get_requires_for_build_wheel ‘c:\users\***\appdata\local\temp\tmpsa5iv2’ Check the logs for full command output.

解决:

需要安装指定版本:

pip install opencv-python==4.2.0.32

 

测试:

def opencv_test(_img):
	img=cv2.imread(_img)
	det=cv2.QRCodeDetector()
	val, pts, st_code = det.detectAndDecode(img)
	print(val)

依然无法识别:

升级到python37 ,也无法使用opencv识别。

使用zxing

python27安装将报错….

python37下 pip install zxing

def main():
	_img = './10-1643467585.jpeg'
	reader = zxing.BarCodeReader()
	barcode = reader.decode(_img)
	print (barcode.parsed)

依然无法识别。。。。

使用在线识别二维码的工具,也都不行。。。

 

 

PS:重新换了个微信号的这个样式二维码,可以识别,应该是图有点糊了。。。OVER

 

赞(0) 打赏
转载请附本站链接,未经允许不得转载,,谢谢:微慑信息网-VulSee.com » python 二维码识别の qrcode | opencv |zxing

评论 抢沙发

微慑信息网 专注工匠精神

微慑信息网-VulSee.com-关注前沿安全态势,聚合网络安全漏洞信息,分享安全文档案例

访问我们联系我们

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册