diff --git a/common/polystar/common/pipeline/debug_pipeline.py b/common/polystar/common/pipeline/debug_pipeline.py index c5822a53d6a664f6e40fd8af1adcc40dc88dcfd7..869e171fb581e28be598595064853ea00ecb4ece 100644 --- a/common/polystar/common/pipeline/debug_pipeline.py +++ b/common/polystar/common/pipeline/debug_pipeline.py @@ -11,6 +11,7 @@ from polystar.common.pipeline.pipeline import Pipeline @dataclass class DebugInfo: + success: bool = False detected_objects: List[Object] = field(init=False) validated_objects: List[Object] = field(init=False) selected_object: Object = field(init=False) @@ -24,9 +25,10 @@ class DebugPipeline(Pipeline): debug_info_: DebugInfo = field(init=False, default_factory=DebugInfo) def predict_target(self, image: Image) -> TargetABC: - self.debug_info_ = DebugInfo() + #self.debug_info_ = DebugInfo() target = super().predict_target(image) self.debug_info_.target = target + self.debug_info_.success = True def predict_best_object(self, image: Image) -> Object: best_object = super().predict_best_object(image) diff --git a/common/polystar/common/view/cv2_results_viewer.py b/common/polystar/common/view/cv2_results_viewer.py index 3894982d9c1ee40a93830b744fdd76e99826b222..30218d2d750e6ee0653997b9b088ff5304c0b91f 100644 --- a/common/polystar/common/view/cv2_results_viewer.py +++ b/common/polystar/common/view/cv2_results_viewer.py @@ -33,6 +33,11 @@ class CV2ResultViewer(ResultViewerABC): self.finished = False super().__init__(COLORS) + def __enter__(self): + cv2.namedWindow(self.name, cv2.WINDOW_NORMAL) + cv2.resizeWindow(self.name, 720, 480) + return self + def __exit__(self, exc_type, exc_val, exc_tb): cv2.destroyWindow(self.name) diff --git a/robots-at-robots/config/settings.toml b/robots-at-robots/config/settings.toml index fe532b09ae715c1a30b4413411f26bbc6bf32145..ec0e56336a1b027e475734bae33f5b8b31469a78 100644 --- a/robots-at-robots/config/settings.toml +++ b/robots-at-robots/config/settings.toml @@ -1,5 +1,5 @@ [default] -MODEL_NAME = 'robots/TRT_ssd_mobilenet_v2_roco.bin' +MODEL_NAME = 'robots/TRT_ssd_mobilenet_v2_roco_2018_03_29_20200314_015411_TWITCH_TEMP_733_IMGS_29595steps.bin' [development] diff --git a/robots-at-robots/research/demos/demo_pipeline_camera.py b/robots-at-robots/research/demos/demo_pipeline_camera.py index b340ec28cab67f8d1ebb581fb00a4871db7d88aa..8e0abd45a640ad44d27904ccb5cfc5edf3caa26d 100644 --- a/robots-at-robots/research/demos/demo_pipeline_camera.py +++ b/robots-at-robots/research/demos/demo_pipeline_camera.py @@ -38,7 +38,7 @@ if __name__ == "__main__": objects_validators=[ConfidenceObjectValidator(0.6), TypeObjectValidator(ObjectType.Armor)], object_selector=ClosestObjectSelector(), target_factory=RatioSimpleTargetFactory(injector.get(Camera), 300, 100), - target_sender=FileDescriptorTargetSender(int(sys.argv[1])), + target_sender=PrintTargetSender(), # FileDescriptorTargetSender(int(sys.argv[1])), ) fps = 0 @@ -48,18 +48,15 @@ if __name__ == "__main__": viewer.new(image) previous_time = time() try: - # inference pipeline.predict_target(image) - - # display + except NoTargetFound: + pass + if pipeline.debug_info_.success: viewer.add_objects(pipeline.debug_info_.validated_objects, forced_color=(0.6, 0.6, 0.6)) viewer.add_object(pipeline.debug_info_.selected_object) + fps = 0.9 * fps + 0.1 / (time() - previous_time) + viewer.add_text(f"FPS: {fps:.1f}", 10, 10, (0, 0, 0)) + viewer.display() - if viewer.finished: - break - except NoTargetFound: - pass - finally: - fps = 0.9 * fps + 0.1 / (time() - previous_time) - viewer.add_text(f"FPS: {fps:.1f}", 10, 10, (0, 0, 0)) - viewer.display() + if viewer.finished: + break