engcang / ros-yolo-sort

YOLO v3, v4, v5, v6, v7 + SORT tracking + ROS platform. Supporting: YOLO with Darknet, OpenCV(DNN), OpenVINO, TensorRT(tkDNN). SORT supports python(original) and C++. (Not Deep SORT)
BSD 3-Clause "New" or "Revised" License
233 stars 38 forks source link

field bounding_boxes[].xmin must be an integer type #2

Closed germal closed 3 years ago

germal commented 3 years ago

Hello @engcang ,

Thank you for sharing this project I'm trying to use ros-sort , but each time I try to echo the /tracked_boxes topic I get the following error

rosrun packagename ros-sort.py /display:=True

.009844064712524414 0.01732325553894043 Traceback (most recent call last): File "/home/mluser/darknet_ws/devel/lib/python3/dist-packages/darknet_ros_msgs/msg/_BoundingBoxes.py", line 109, in serialize buff.write(_get_struct_d4qh().pack(_x.probability, _x.xmin, _x.ymin, _x.xmax, _x.ymax, _x.id)) struct.error: required argument is not an integer .... Traceback (most recent call last): File "/home/mluser/darknet_ws/src/darknet_ros/darknet_ros/scripts/ros-sort.py", line 351, in mot_tracker.pubb.publish(r) File "/home/mluser/catkin3_ws/install/lib/python3/dist-packages/rospy/topics.py", line 886, in publish raise ROSSerializationException(str(e)) rospy.exceptions.ROSSerializationException: field bounding_boxes[].xmin must be an integer type

EDIT the error triggers immediately or sometimes after 30 seconds and . Even if darknet_ros correctly detects the class ( person in this case) , the field bounding box stay always empty : image_header: seq: 0 stamp: secs: 0 nsecs: 0 frame_id: '' bounding_boxes: [] I am using python3 on ROS, maybe some statement not compatible with Python3 ?

Could you please help to find a solution ? Thanks Regards germal

engcang commented 3 years ago

Hi. I am slightly confused now. At the beginning of your question, you said you tried to echo /tracked_boxes topic and got an error. But according to your error, I guess this is not the error from my code.

As you mentioned, and as your error, this seems compatibility issue between python3 and ROS. Especially because of Darknet_ROS.

I recommend you to use Python2 with ROS. Until Ubuntu 18.04LTS - ROS Melodic distro, automatically python2 is used with ROS I heard from somewhere from 20.04LTS, ROS is hardly working and also ROS is hardly working with Python3.

Please check if you can get consistently stable data via $ rostopic echo /darknet_ros/bounding_boxes when you only run the darknet_ros but not ros-sort.

After that, try to use ros-sort please!

germal commented 3 years ago

Hi @engcang

Thank you for your reply .Yeah , my ROS version is not a "standard" melodic because it is compiled with Python3 ,but only for testing . After some research I found

engcang commented 3 years ago

@germal Can you share your rosbag data including image and darknet_ros/bounding_boxes topic?

I want to test it myself.

I am suspecting one potential issue from my code now. If you look at the ros_sort_python folder, I have 'ros_sort.py' and one old backup version code.

Maybe old version code will work stable because I recently changed the code to update the kalman filter every frame, even if there is no bounding boxes coming in, since this way is the exactly same with the original sort algorithm. But the former, old version code also worked well.

Anyway, if you can share your rosbag data with me, i will try to run it myself with Python version 2. If I can make it run stable with Python2, then we can consider next step.

germal commented 3 years ago

Hello I think that something happens here trackers = self.update(dets) printing trackers from the script bootstrap, there is only the print of the first track values. Thanks germal

germal commented 3 years ago

Hello @engcang ! I have recorded a short rosbag with the relevant topics on a Jetson Nano with a standard melodic Python2.Thank you very much for your dedicated support ! Please find the bag here Regards germal

engcang commented 3 years ago

@germal

Well, with python version 2, it works fine. I attach the video clip of result on your rosbag data https://youtu.be/JjfRlpNEz2c

Now I think you also have to edit some part of my code as you mentioned before, I mean replacing some lines of my code's "Int32" with "int".

Actually I just wanted to test my code (original Python version2) with your data, if it works or not and I do not have ROS-Python3 environment now. So testing with that environment would be difficult for me

germal commented 3 years ago

Hello @engcang , I am so grateful to you to dedicate time for testing my case. Putting the code at original ( without int32->int modification) and thinking at what the error message says: rospy.exceptions.ROSSerializationException: field bounding_boxes[].xmin must be an integer type I put a casting in the fields on the published message r = BoundingBoxes() for d in range(len(trackers)): rb = BoundingBox() rb.probability=1 rb.xmin = int(trackers[d,0]) rb.ymin = int(trackers[d,1]) rb.xmax = int(trackers[d,2]) rb.ymax = int(trackers[d,3]) rb.id = int(trackers[d,4])

and now the message appears also in my python3 Melodic `header seq: 56 stamp secs 1607185072 nsecs: 900479555 frame_id image_header seq: 0 stamp: secs: 0 nsecs: 0 frame_id: bounding_boxes

probability 1.0
xmin: 251
ymin: 0
xmax: 523
ymax: 474
id: 2
Class: "tracked"

header: seq: 57 stamp: secs: 1607185073 nsecs: 635974407 frame_id: image_header seq: 0 stamp: secs: 0 nsecs: 0 frame_id: bounding_boxes

probability: 1.0
xmin: 252
ymin: 0
xmax: 524
ymax: 475
id: 2
Class: "tracked"

` Could you please test if this modification maybe invalidate the output ? Thanks for your help Regards germal

engcang commented 3 years ago

@germal That seems totally fine and great to hear that you made it work with Python3-ROS.

Let me add int() type in the original code with my own. Also take a note that I removed the empty boxes in the edited code. which is, the box with

xmin: 0 ymin: 0 xmax: 0 ymax: 0

Thank you for your attention on my repo.