Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recognize_raw_image_func conflict with numpy #508

Open
cdavi014 opened this issue May 18, 2017 · 4 comments
Open

recognize_raw_image_func conflict with numpy #508

cdavi014 opened this issue May 18, 2017 · 4 comments

Comments

@cdavi014
Copy link

Hi, I am using a virtual python environment, and I have an issue where when I install Numpy and try to run openalpr, I get the following error:

File "/usr/local/lib/python2.7/site-packages/openalpr/openalpr.py", line 85, in __init__
    self._recognize_raw_image_func = self._openalprpy_lib.recognizeRawImage
  File "/usr/lib/python2.7/ctypes/__init__.py", line 375, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 380, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/libopenalprpy.so: undefined symbol: recognizeRawImage
Exception AttributeError: "Alpr instance has no attribute 'loaded'" in <bound method Alpr.__del__ of <openalpr.openalpr.Alpr instance at 0x7fe4cfcfa4d0>> ignored

I have identified the code in openlpr.py where it stems from:

        try:
            import numpy as np
            import numpy.ctypeslib as npct
            self._recognize_raw_image_func = self._openalprpy_lib.recognizeRawImage
            self._recognize_raw_image_func.restype = ctypes.c_void_p
            array_1_uint8 = npct.ndpointer(dtype=np.uint8, ndim=1, flags='CONTIGUOUS')
            self._recognize_raw_image_func.argtypes = [
                ctypes.c_void_p, array_1_uint8, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint]
        except ImportError:
            self._recognize_raw_image_func = None

If I comment out the code, it works just fine. If I don't have Numpy installed it works just fine. I am not sure what I am doing wrong.

@r1me
Copy link

r1me commented May 18, 2017

Hi, I've got the same issue.
Latest openalprpy.cpp does export recognizeRawImage. At the same time, latest release build actually does not export this function:

??0Alpr@alpr@@QAE@ABV01@@Z: 1
??4Alpr@alpr@@QAEAAV01@ABV01@@Z: 2
??_7Alpr@alpr@@6B@: 3
dispose: 4
freeJsonMem: 5
getVersion: 6
initialize: 7
isLoaded: 8
recognizeArray: 9
recognizeFile: 10
setCountry: 11
setDefaultRegion: 12
setDetectRegion: 13
setPrewarp: 14
setTopN: 15

Solved by rebuilding openalprpy with recognizeRawImage exported.

@iontom
Copy link

iontom commented Nov 29, 2017

@r1me - what's the build process for openalprpy? I try running the make file but nothing changes.

@birolkuyumcu
Copy link

same issue with prebuild releases
first
dll file name is wrong

self._openalprpy_lib = ctypes.cdll.LoadLibrary("libopenalprpy.dll")
so openalprpy.dll renamed as libopenalprpy.dll
than

AttributeError: function 'recognizeRawImage' not found

rises
i try OpenALPR 2.3.0 and OpenALPR 2.2.0 release same
recognizeRawImage not exported

@avrcore
Copy link

avrcore commented Nov 27, 2018

Same Issue here. Is uninstalling numpy my only option? Is there another workaround? Took me 12h to boil it down to here...

cclauss added a commit to cclauss/openalpr that referenced this issue Nov 25, 2021
There are currently [46 open issues related to `loaded`](https://github.com/openalpr/openalpr/search?p=2&q=loaded&type=issues).  Many of these [`AttributeError` issues](https://github.com/openalpr/openalpr/search?q=AttributeError&type=issues) are caused because `self.loaded` is only defined at the end of this method on (line 117).  If an exception is raised (like line 62, etc.) then `self.loaded` is _never_ defined so subsequent code fails when trying to determine if `Alpr` has successfully loaded.

Closes openalpr#311
Closes openalpr#414
Closes openalpr#426
Closes openalpr#461 
Closes openalpr#508
Closes openalpr#533
Closes openalpr#660
Closes openalpr#732
Closes openalpr#738
Closes openalpr#764
Closes openalpr#806
Closes openalpr#837 
Closes openalpr#913 
Closes openalpr#916 
Related to openalpr#555
Related to Homebrew/homebrew-core#89948
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants