Closed mrigankEvig closed 1 month ago
Hello.
If you are having problems with rectangle drawing it must be either the wrong bounding box format that you are using or you made some mistake with the scaling. If you scale the detections as done in line 192 of boost_track.py file, the results which you get do not require further scaling.
Here is an example of method which can be added to KalmanBoxTracker class which draws the bounding box:
def draw_bbox(self, img: np.ndarray) -> np.ndarray:
box = self.get_state().reshape((4, ))
x0 = int(box[0])
y0 = int(box[1])
x1 = int(box[2])
y1 = int(box[3])
#
text = "{}".format(self.id)
font = cv2.FONT_HERSHEY_SIMPLEX
txt_size = cv2.getTextSize(text, font, 0.4, 1)[0]
cv2.rectangle(img, (x0, y0), (x1, y1), self.color, 2)
txt_bk_color = (np.array(self.color) * 0.7).astype(np.uint8).tolist()
cv2.rectangle(
img,
(x0, y0 + 1),
(x0 + txt_size[0] + 1, y0 + int(1.5 * txt_size[1])),
txt_bk_color,
-1,
)
cv2.putText(
img, text, (x0, y0 + txt_size[1]), font, 0.4, self.color, thickness=1
)
return img
The img
parameter used is img_numpy
(see the definition of update method in line 173: def update(self, dets, img_tensor, img_numpy, tag):
)
@mrigankEvig
This is the code function i am using to plot bounding boxes
`def draw_bounding_boxes(image, online_tlwhs, online_ids, online_conf,scale): height, width = image.shape[:2]
'det' i pass to tracker.update are normalized
targets = tracker.update(det, img, frame[0], tag)