diff --git a/peekingduck/configs/output/screen.yml b/peekingduck/configs/output/screen.yml index c60012f95..9f979ff07 100644 --- a/peekingduck/configs/output/screen.yml +++ b/peekingduck/configs/output/screen.yml @@ -1,2 +1,13 @@ input: ["img"] -output: ["pipeline_end"] \ No newline at end of file +output: ["pipeline_end"] + +window_name: "PeekingDuck" +window_size: { + do_resizing: False, + width: 1280, + height: 720 +} +window_loc: { + x: 0, + y: 0 +} \ No newline at end of file diff --git a/peekingduck/pipeline/nodes/output/screen.py b/peekingduck/pipeline/nodes/output/screen.py index a5a8d16a4..503ad5fb2 100644 --- a/peekingduck/pipeline/nodes/output/screen.py +++ b/peekingduck/pipeline/nodes/output/screen.py @@ -33,17 +33,35 @@ class Node(AbstractNode): |pipeline_end| Configs: - None. + window_name (:obj:`str`): **default = "PeekingDuck"** |br| + Name of the displayed window. + window_size (:obj:`Dict`): + **default = { do_resizing: False, width: 1280, height: 720 }** |br| + Resizes the displayed window to the chosen width and weight, if ``do_resizing`` + is set to ``true``. The size of the displayed window can also be adjusted by + clicking and dragging. + window_loc (:obj:`Dict`): **default = { x: 0, y: 0 }** |br| + X and Y coordinates of the top left corner of the displayed window, with + reference from the top left corner of the screen, in pixels. """ def __init__(self, config: Dict[str, Any] = None, **kwargs: Any) -> None: super().__init__(config, node_path=__name__, **kwargs) + cv2.namedWindow(self.window_name, cv2.WINDOW_NORMAL) + cv2.moveWindow(self.window_name, self.window_loc["x"], self.window_loc["y"]) def run(self, inputs: Dict[str, Any]) -> Dict[str, Any]: """Show the outputs on your display""" - cv2.imshow("PeekingDuck", inputs["img"]) + + img = inputs["img"] + if self.window_size["do_resizing"]: + img = cv2.resize( + img, (self.window_size["width"], self.window_size["height"]) + ) + cv2.imshow(self.window_name, img) if cv2.waitKey(1) & 0xFF == ord("q"): + cv2.destroyWindow(self.window_name) return {"pipeline_end": True} return {"pipeline_end": False}