diff --git a/trap/config.py b/trap/config.py index 180d00f..d782ee4 100644 --- a/trap/config.py +++ b/trap/config.py @@ -183,22 +183,22 @@ inference_parser.add_argument("--z-mode", connection_parser.add_argument('--zmq-trajectory-addr', help='Manually specity communication addr for the trajectory messages', type=str, - default="ipc:///tmp/feeds/traj") + default="ipc:///tmp/feeds_traj") connection_parser.add_argument('--zmq-camera-stream-addr', help='Manually specity communication addr for the camera stream messages', type=str, - default="ipc:///tmp/feeds/img") + default="ipc:///tmp/feeds_img") connection_parser.add_argument('--zmq-prediction-addr', help='Manually specity communication addr for the prediction messages', type=str, - default="ipc:///tmp/feeds/preds") + default="ipc:///tmp/feeds_preds") connection_parser.add_argument('--zmq-frame-addr', help='Manually specity communication addr for the frame messages', type=str, - default="ipc:///tmp/feeds/frame") + default="ipc:///tmp/feeds_frame") connection_parser.add_argument('--ws-port', @@ -252,6 +252,9 @@ tracker_parser.add_argument("--smooth-tracks", render_parser.add_argument("--render-file", help="Render a video file previewing the prediction, and its delay compared to the current frame", action='store_true') +render_parser.add_argument("--render-window", + help="Render a previewing to a window", + action='store_true') render_parser.add_argument("--render-url", help="""Stream renderer on given URL. Two easy approaches: diff --git a/trap/frame_emitter.py b/trap/frame_emitter.py index f54d115..abe1232 100644 --- a/trap/frame_emitter.py +++ b/trap/frame_emitter.py @@ -145,7 +145,15 @@ class FrameEmitter: i = 0 for video_path in self.video_srcs: logger.info(f"Play from '{str(video_path)}'") - video = cv2.VideoCapture(str(video_path)) + if str(video_path).isdigit(): + # numeric input is a CV camera + video = cv2.VideoCapture(int(str(video_path))) + video.set(cv2.CAP_PROP_FRAME_WIDTH, int(1280)) + video.set(cv2.CAP_PROP_FRAME_HEIGHT, int(720)) + print("exposure!", video.get(cv2.CAP_PROP_AUTO_EXPOSURE)) + video.set(cv2.CAP_PROP_FPS, 1) + else: + video = cv2.VideoCapture(str(video_path)) fps = video.get(cv2.CAP_PROP_FPS) target_frame_duration = 1./fps logger.info(f"Emit frames at {fps} fps") diff --git a/trap/plumber.py b/trap/plumber.py index 3dd440d..a70d0f5 100644 --- a/trap/plumber.py +++ b/trap/plumber.py @@ -73,7 +73,7 @@ def start(): ExceptionHandlingProcess(target=run_tracker, kwargs={'config': args, 'is_running': isRunning}, name='tracker'), ] - if args.render_file or args.render_url: + if args.render_file or args.render_url or args.render_window: procs.append( ExceptionHandlingProcess(target=run_renderer, kwargs={'config': args, 'is_running': isRunning}, name='renderer') ) diff --git a/trap/renderer.py b/trap/renderer.py index c01764d..4f3d601 100644 --- a/trap/renderer.py +++ b/trap/renderer.py @@ -81,6 +81,10 @@ class Renderer: self.out_writer = self.start_writer() if self.config.render_file else None self.streaming_process = self.start_streaming() if self.config.render_url else None + if self.config.render_window: + cv2.namedWindow("frame", cv2.WND_PROP_FULLSCREEN) + cv2.setWindowProperty("frame",cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN) + def start_writer(self): if not self.config.output_dir.exists(): raise FileNotFoundError("Path does not exist") @@ -147,11 +151,15 @@ class Renderer: # cv2.imwrite(str(img_path), img) - logger.debug(f"write frame {frame.time - first_time:.3f}s") + logger.info(f"write frame {frame.time - first_time:.3f}s") if self.out_writer: self.out_writer.write(frame.img) if self.streaming_process: self.streaming_process.stdin.write(frame.img.tobytes()) + if self.config.render_window: + print('show') + cv2.imshow('frame',frame.img) + cv2.waitKey(1) logger.info('Stopping') if i>2: