stereolabs / zed-python-api

Python API for the ZED SDK
https://www.stereolabs.com/docs/app-development/python/install/
MIT License
209 stars 95 forks source link

module 'pyzed.sl' has no attribute 'OBJECT_TRACK_STATE' #126

Closed TaynaCT closed 4 years ago

TaynaCT commented 4 years ago

So I'm building an app in python for the ZED 2 using Objects detection module. O the main thread I try to see the OBJECT_TRACK_STATE. But once in a while, when the camera detects a lot of things, the program throws this error message:

Exception in thread Thread-3:
Traceback (most recent call last):
  File "C:\Users\unloo\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Users\unloo\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\unloo\PycharmProjects\test\manager\zed\zed_manager.py", line 137, in start_async
    if i < self.player_num or object_state != sl.OBJECT_TRACK_STATE.OK:
AttributeError: module 'pyzed.sl' has no attribute 'OBJECT_TRACK_STATE'

What is going on? These are the conditions I have on my code:

                    if object_id is 4294967295:
                        continue

                    if object_state is None:
                        continue

                    if self.data is None:
                        if i < self.player_num or object_state != sl.OBJECT_TRACK_STATE.OK:
                            self.data = bytes(('{"id": ' + str(object_id) + ', "tracking_state": "' + str(object_state) +
                                               '", "position": [' + str(object_position[0]) + ',' +
                                               str(object_position[1]) + ',' + str(object_position[2]) + ']}'), 'UTF-8')

zed2 #pyzed.sl

abastie commented 4 years ago

Hi @TaynaCT ,

In SDK 3.0, there is no OBJECT_TRACK_STATE but there is OBJECT_TRACKING_STATE instead.

TaynaCT commented 4 years ago

Hi @Poutsh ,

apparently this was the problem. Thank you. But just FYI, on this page( https://www.stereolabs.com/docs/object-detection/using-object-detection/ ) on the ACCESSING OBJECT INFORMATION section, they put wrong info :( The example they give is:

if object_tracking_state == sl.OBJECT_TRACK_STATE.OK :
    print("Object {0} is tracked\n".format(object_id))

it shoud be sl.OBJECT_TRACKING_STATE.OK instead.

Thank you for your help. :)