1

首先,我从这里下载了 OpenALPR src 和二进制文件: Release ( src & binary )

在 C:\OpenALPR 中提取 src 和二进制文件,然后我将 C:\OpenALPIR\openalpr_64 添加到我的路径(环境变量 -> 路径 -> 编辑 -> 新建),然后我从 src/bindings/python 运行 follownig 命令

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

之后,我将目录更改为 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 我从二进制文件夹复制 openalprpy.dll 并粘贴到 Python\Python36\Lib\site-packages\openalpr 这已经解决了问题,但我认为它不是故意的?

4

1 回答 1

1

非常感谢复制 openalprpy.dll 的提示。但是,我在 Linux 上,这里的修复略有不同。

我想我搞砸了,因为我之前通过 pip 安装了 openalpr,它安装了 1.1.0 版。然后我通过 pip 卸载了 openalpr 并从openalpr/src/bindings/python/with安装了它python setup.py install,但不知何故我仍然得到了AttributeError: 'Alpr' object has no attribute 'loaded'.

感谢此处的 OP,我将libopenalprpy.so(Linux 等效项openalprpy.dll)从openalpr/src/bindings/python/to复制了/usr/lib/,它覆盖了一个同名的文件,该文件可能仍然存在于错误的 openalpr 1.1.0 安装中。您需要 sudo 权限才能做到这一点。之后我可以像 OP 一样使用 python 绑定。

这是在 Jetson Nano 上使用 Ubuntu 18.04 完成的。

于 2021-02-04T10:29:55.697 回答