From 2434470cdf9abf0923b124526e624053d58ae9de Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Fri, 20 Oct 2023 18:48:59 +0200 Subject: [PATCH] bypass renderer reads tracker data --- trap/renderer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/trap/renderer.py b/trap/renderer.py index b3324cd..4b29516 100644 --- a/trap/renderer.py +++ b/trap/renderer.py @@ -22,13 +22,12 @@ class Renderer: self.prediction_sock = context.socket(zmq.SUB) self.prediction_sock.setsockopt(zmq.CONFLATE, 1) # only keep latest frame. NB. make sure this comes BEFORE connect, otherwise it's ignored!! self.prediction_sock.setsockopt(zmq.SUBSCRIBE, b'') - self.prediction_sock.connect(config.zmq_prediction_addr) + self.prediction_sock.connect(config.zmq_prediction_addr if not self.config.bypass_prediction else config.zmq_trajectory_addr) self.frame_sock = context.socket(zmq.SUB) self.frame_sock.setsockopt(zmq.CONFLATE, 1) # only keep latest frame. NB. make sure this comes BEFORE connect, otherwise it's ignored!! self.frame_sock.setsockopt(zmq.SUBSCRIBE, b'') self.frame_sock.connect(config.zmq_frame_addr) - self.H = np.loadtxt(self.config.homography, delimiter=',') @@ -73,10 +72,12 @@ class Renderer: for track_id, prediction in predictions.items(): if not 'history' in prediction or not len(prediction['history']): continue + coords = cv2.perspectiveTransform(np.array([prediction['history']]), self.inv_H)[0] # logger.warning(f"{coords=}") center = [int(p) for p in coords[-1]] cv2.circle(img, center, 5, (0,255,0)) + cv2.putText(img, track_id, (center[0]+8, center[1]), cv2.FONT_HERSHEY_SIMPLEX, fontScale=.8, color=(0,255,0)) for ci in range(1, len(coords)): start = [int(p) for p in coords[ci-1]] @@ -91,7 +92,7 @@ class Renderer: for ci in range(1, len(pred_coords)): start = [int(p) for p in pred_coords[ci-1]] end = [int(p) for p in pred_coords[ci]] - cv2.line(img, start, end, (0,0,255), 2) + cv2.line(img, start, end, (0,0,255), 1)