openalpr / openalpr

Automatic License Plate Recognition library
http://www.openalpr.com
GNU Affero General Public License v3.0
11.04k stars 2.5k forks source link

Run openalpr using Python #855

Open Lepiloff opened 5 years ago

Lepiloff commented 5 years ago

Hello! At Ubuntu 18.04 I successfully installed openalpr and tested it. Now I want to use python to call it. To do this, I installed https://pypi.org/project/openalpr/

pip install openalpr

But I'm having trouble with the paths, the ones in the example don't work.

alpr = Alpr("eu", "/etc/openalpr/openalpr.conf", "/usr/share/openalpr/runtime_data")

I get an error

>>> from openalpr import Alpr
>>> alpr = Alpr("eu", "/etc/openalpr/openalpr.conf", "/usr/share/openalpr/runtime_data")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/y700/Env/carplate/lib/python3.7/site-packages/openalpr/openalpr.py", line 95, in __init__
    self._add_encoded_image_to_batch_func = self._openalprpy_lib.openalpr_add_encoded_image_to_batch
  File "/home/y700/anaconda3/lib/python3.7/ctypes/__init__.py", line 369, in __getattr__
    func = self.__getitem__(name)
  File "/home/y700/anaconda3/lib/python3.7/ctypes/__init__.py", line 374, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/libopenalpr.so.2: undefined symbol: openalpr_add_encoded_image_to_batch
Lepiloff commented 5 years ago

After a few hours of searching, I found a solution that doesn't require a package installation pip install openalpr

Go to

cd openalpr/src/bindings/python/

run

`sudo python3 setup.py install`

set the alpr value

`alpr = Alpr("us", "/etc/openalpr/openalpr.conf", "/usr/share/openalpr/runtime_data/") `

Thats all!

Lepiloff commented 5 years ago

Only one question. On the root of openalpr there is folder runtime_data, is this the same folder as /usr/share/openalpr/runtime_data/? Which path to the folder should I use more correctly?

dhrumin75 commented 4 years ago

Do we have to purchase a license key? I followed your steps but I am getting 'Licensing Error'

SundayFunday commented 4 years ago

After a few hours of searching, I found a solution that doesn't require a package installation pip install openalpr

Go to

cd openalpr/src/bindings/python/

run

`sudo python3 setup.py install`

set the alpr value

`alpr = Alpr("us", "/etc/openalpr/openalpr.conf", "/usr/share/openalpr/runtime_data/") `

Thats all!

Huge help! Thanks! One clarification: I still needed pip install openalpr for this to work.

SundayFunday commented 4 years ago

After a few hours of searching, I found a solution that doesn't require a package installation pip install openalpr Go to cd openalpr/src/bindings/python/ run

`sudo python3 setup.py install`

set the alpr value

`alpr = Alpr("us", "/etc/openalpr/openalpr.conf", "/usr/share/openalpr/runtime_data/") `

Thats all!

Huge help! Thanks! One clarification: I still needed pip install openalpr for this to work.

Actually, I had to do one more thing: add openalpr/src/bindings/python/openalpr to my PYTHONPATH

karborator commented 3 years ago

Do we have to purchase a license key? I followed your steps but I am getting 'Licensing Error'