diff --git a/trap/renderer.py b/trap/renderer.py index d2b64cc..b3324cd 100644 --- a/trap/renderer.py +++ b/trap/renderer.py @@ -30,9 +30,9 @@ class Renderer: self.frame_sock.connect(config.zmq_frame_addr) - H = np.loadtxt(self.config.homography, delimiter=',') + self.H = np.loadtxt(self.config.homography, delimiter=',') - self.inv_H = np.linalg.pinv(H) + self.inv_H = np.linalg.pinv(self.H) if not self.config.output_dir.exists(): raise FileNotFoundError("Path does not exist") @@ -57,8 +57,19 @@ class Renderer: predictions = self.prediction_sock.recv_json(zmq.NOBLOCK) except zmq.ZMQError as e: logger.debug(f'reuse prediction') - + img = frame.img + + # all not working: + # if i == 1: + # # thanks to GpG for fixing scaling issue: https://stackoverflow.com/a/39668864 + # scale_factor = 1./20 # from 10m to 1000px + # S = np.array([[scale_factor, 0,0],[0,scale_factor,0 ],[ 0,0,1 ]]) + # new_H = S * self.H * np.linalg.inv(S) + # warpedFrame = cv2.warpPerspective(img, new_H, (1000,1000)) + # cv2.imwrite(str(self.config.output_dir / "orig.png"), warpedFrame) + + for track_id, prediction in predictions.items(): if not 'history' in prediction or not len(prediction['history']): continue @@ -94,7 +105,9 @@ class Renderer: # cv2.imwrite(str(img_path), img) self.out.write(img) logger.info('Stopping') - self.out.release() + + if i>2: + self.out.release()