0

After downloading the precompiled binaries for Windows of the openALPR library, running the setup.py included in the source code to install it, and running the python_test.bat included in the precompiled binaries directory I get the following error:

File "C:\Users\rhenriquez\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openalpr\openalpr.py", line 51, in __init__
    self._openalprpy_lib = ctypes.cdll.LoadLibrary("libopenalprpy.dll")
  File "C:\Users\rhenriquez\AppData\Local\Programs\Python\Python37-32\lib\ctypes\__init__.py", line 434, in LoadLibrary
    return self._dlltype(name)
  File "C:\Users\rhenriquez\AppData\Local\Programs\Python\Python37-32\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: OSError: [WinError 193] %1 is not a valid Win32 application

When I started to run the script at first the error was WinError 126 and then I noticed that the dll that the script was trying to call (openalprpy.dll) didn't had "lib" at the beginning of its name, so I added it to the dll's name. Then it started to send me WinError 193, and I've been clueless on what else to do or what am I doing wrong from then on.

Any help would be appreciated.

1 Answers1

2

EDIT: So I tried this with the 32-bit version and it gives the same error you are encountering. This appears to be an issue with trying to import a 32-bit .dll while using 64-bit python, or vice-versa, as seen in Python Ctypes Load Library

/EDIT

I did get it to work on my system... with a few modifications, this package is not as "plug and play" as it should be.

I don't know where I went right, so I'll just list what I did:

Download the pre-compiled biniaries from releases (I used openalpr-2.3.0-win-64bit.zip) https://github.com/openalpr/openalpr/releases

Download the project itself, https://github.com/openalpr/openalpr

Unzip both.

Goto the bindings folder in openalpr-master cd C:\openalpr-master\openalpr-master\src\bindings\python and run python setup.py install to make the bindings.

Then navigate to the project folder in site-packages, most likely C:\Users\rhenriquez\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openalpr\ and open openalpr.py in IDLE,

here you can change line 51 from self._openalprpy_lib = ctypes.cdll.LoadLibrary("libopenalprpy.dll") to self._openalprpy_lib = ctypes.cdll.LoadLibrary("openalprpy.dll") since it appears other links are broken if you change the file name.

I also found it beneficial to change line 90 to except Exception: since it did not want to import correctly and was not raising an ImportError.

After that the python_test.bat worked correctly.

Namespace(config='openalpr.conf', country='us', plate_image='samples/us-1.jpg', runtime_data='runtime_data')
Using OpenALPR 2.3.0
Image size: 497x372
Processing Time: 561.825989
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
Press any key to continue . . .
tgikal
  • 1,667
  • 1
  • 13
  • 27
  • 1
    Thank you so much!! Your edit was the one that did it for me. For some reason, I didn't pay attention and installed 32-bit Python instead of the 64-bit. Now it's working! Thank you! – Roy Henriquez Jan 24 '19 at 13:45