pupil-labs / apriltags

Python bindings for the apriltags3 library
https://pupil-apriltags.readthedocs.io/en/latest/index.html
Other
106 stars 29 forks source link

'Detector' object has no attribute 'tag_detector_ptr' or ValueError: the environment variable is longer than 32767 characters #37

Open TON14 opened 3 years ago

TON14 commented 3 years ago

Error

Traceback (most recent call last):
  File "apriltags.py", line 75, in <module>
    debug=0)
  File "C:\Users\main\AppData\Local\Programs\Python\Python37\lib\site-packages\pupil_apriltags\bindings.py", line 273, in __init__
    os.environ["PATH"] = dll_path + os.pathsep + os.environ["PATH"]
  File "C:\Users\main\AppData\Local\Programs\Python\Python37\lib\os.py", line 687, in __setitem__
    self.putenv(key, value)
ValueError: the environment variable is longer than 32767 characters
Exception ignored in: <function Detector.__del__ at 0x000001CE22927798>
Traceback (most recent call last):
  File "C:\Users\main\AppData\Local\Programs\Python\Python37\lib\site-packages\pupil_apriltags\bindings.py", line 368, in __del__
    if self.tag_detector_ptr is not None:
AttributeError: 'Detector' object has no attribute 'tag_detector_ptr'
TON14 commented 3 years ago

FIX

in python\Lib\site-packages\pupil_apriltags\bindings.py Replace

        if platform.system() == "Windows":
            # the apriltags dll depends on pthreads-win, we inject our pre-built libs
            # into the path before loading with ctypes
            import pupil_pthreads_win
            dll_path = str(pupil_pthreads_win.dll_path.parent.resolve())
            os.environ["PATH"] = dll_path + os.pathsep + os.environ["PATH"]

to

        if platform.system() == "Windows":
            # the apriltags dll depends on pthreads-win, we inject our pre-built libs
            # into the path before loading with ctypes
            import pupil_pthreads_win
            dll_path = str(pupil_pthreads_win.dll_path.parent.resolve())
            os.environ["PATH"] = dll_path + os.pathsep
eichex commented 2 years ago

Have the same Problem, but mentioned lines are now

if platform.system() == "Windows":
            # the apriltags dll depends on pthreads-win, we inject our pre-built libs
            # into the path before loading with ctypes
            import pupil_pthreads_win

            dll_path = str(pupil_pthreads_win.dll_path.parent.resolve())
            os.add_dll_directory(dll_path)

Interesting part: I call a function creating a Detector in a loop. After several iterations, where the detector works, i get Exception ignored in: <function Detector.__del__ at 0x000001D69309A820> Traceback (most recent call last): File "C:\ProgramData\Anaconda3\envs\Tags220907\lib\site-packages\pupil_apriltags\bindings.py", line 371, in __del__ if self.tag_detector_ptr is not None: AttributeError: 'Detector' object has no attribute 'tag_detector_ptr'

If i increase the quad_decimate, i get more iteration, but I still get the above mentioned error. Any Suggestions?