Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable options to improve output.screen node #547

Merged
merged 5 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion peekingduck/configs/output/screen.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
input: ["img"]
output: ["pipeline_end"]
output: ["pipeline_end"]

window_name: "PeekingDuck"
window_size: {
do_resizing: False,
width: 1280,
height: 720
}
window_loc: {
x: 0,
y: 0
}
22 changes: 20 additions & 2 deletions peekingduck/pipeline/nodes/output/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
ongtw marked this conversation as resolved.
Show resolved Hide resolved