首先,我从这里下载了OpenALPR源码和二进制文件:Release ( src & binary)
在C:\OpenALPR中解压src和二进制文件,然后将C:\OpenALPIR\openalpr_64添加到我的路径中(环境变量->路径->编辑python新建),然后从src/ -> /python运行以下命令
c:\OpenALPR\openalpr-2.3.0\src\bindings\python>python setup.py build
running build
running build_py
creating build
creating build\lib
creating build\lib\openalpr
copying openalpr\openalpr.py -> build\lib\openalpr
copying openalpr\__init__.py -> build\lib\openalpr
c:\OpenALPR\openalpr-2.3.0\src\bindings\python>python setup.py install
running install
running build
running build_py
running install_lib
running install_egg_info
Removing C:\Users\Danial\AppData\Local\Programs\Python\Python36\Lib\site-packages\openalpr-1.0-py3.6.egg-info
Writing C:\Users\Danial\AppData\Local\Programs\Python\Python36\Lib\site-packages\openalpr-1.0-py3.6.egg-info之后,我将我的dir更改为alpr所在的目录。
c:\OpenALPR\openalpr-2.3.0\src\bindings\python>cd c:\OpenALPR\openalpr_64然后我运行了python_test.bat
c:\OpenALPR\openalpr_64>python_test.bat
Traceback (most recent call last):
File "C:\Users\Danial\AppData\Local\Programs\Python\Python36\lib\site-packages\openalpr\openalpr.py", line 51, in __init__
self._openalprpy_lib = ctypes.cdll.LoadLibrary("libopenalprpy.dll")
File "C:\Users\Danial\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 426, in LoadLibrary
return self._dlltype(name)
File "C:\Users\Danial\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "python/test.py", line 21, in <module>
alpr = Alpr(options.country, options.config, options.runtime_data)
File "C:\Users\Danial\AppData\Local\Programs\Python\Python36\lib\site-packages\openalpr\openalpr.py", line 61, in __init__
raise nex
OSError: Unable to locate the OpenALPR library. Please make sure that OpenALPR is properly installed on your system and that the libraries are in the appropriate paths.
Exception ignored in: <bound method Alpr.__del__ of <openalpr.openalpr.Alpr object at 0x000001D89B9B2D68>>
Traceback (most recent call last):
File "C:\Users\Danial\AppData\Local\Programs\Python\Python36\lib\site-packages\openalpr\openalpr.py", line 258, in __del__
File "C:\Users\Danial\AppData\Local\Programs\Python\Python36\lib\site-packages\openalpr\openalpr.py", line 135, in is_loaded
AttributeError: 'Alpr' object has no attribute 'loaded'
Press any key to continue . . .但是如果我从src文件夹运行test.py,即:
C:\OpenALPR\openalpr-2.3.0\src\bindings\python>python test.py -c us --config "c:\OpenALPR\openalpr_64\openalpr.conf" --runtime_data "c:\OpenALPR\openalpr_64\runtime_data" c:\OpenALPR\openalpr_64\samples\us-1.jpg
Using OpenALPR 2.3.0
Image size: 497x372
Processing Time: 1258.149048
Plate #1
Plate Confidence
- THECAR 92.207481
- THEGAR 81.348961
- HECAR 80.229317
- TMECAR 78.159492
- THE0AR 77.702461
- THECAB 77.389000
- THEAR 76.510017这个错误是由于我从二进制文件夹中复制openalprpy.dll并粘贴到Python\Python36\Lib\site-packages\openalpr中导致的。这个问题已经解决了,但我认为这不是故意的?
发布于 2021-02-04 18:29:56
非常感谢关于复制openalprpy.dll的提示。然而,我使用的是Linux,这里的修复略有不同。
我想我搞砸了,因为我之前通过pip安装了openalpr,它安装了1.1.0版本。然后我通过pip卸载了openalpr,然后用python setup.py install从openalpr/src/bindings/python/上安装了它,但不知何故我还是得到了AttributeError: 'Alpr' object has no attribute 'loaded'。
多亏了这里的OP,我将libopenalprpy.so (Linux版的openalprpy.dll)从openalpr/src/bindings/python/复制到了/usr/lib/,它覆盖了一个同名的文件,这个文件可能仍然存在于错误的openalpr 1.1.0安装中。你需要sudo特权才能做到这一点。之后,我可以像使用OP一样使用python绑定。
这是用Ubuntu 18.04在Jetson Nano上完成的。
https://stackoverflow.com/questions/59175164
复制相似问题