-
Notifications
You must be signed in to change notification settings - Fork 38
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
Changes from 1 commit
901b4a7
9fe2def
aafeb28
98d3f78
9762dc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
input: ["img"] | ||
output: ["pipeline_end"] | ||
output: ["pipeline_end"] | ||
|
||
window_name: PeekingDuck | ||
window_width: 1280 | ||
window_height: 720 | ||
window_x_coord: 0 | ||
window_y_coord: 0 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,17 +33,33 @@ class Node(AbstractNode): | |
|pipeline_end| | ||
|
||
Configs: | ||
None. | ||
window_name (:obj:`str`): **default = "PeekingDuck"** |br| | ||
Name of the displayed window. | ||
window_width (:obj:`int`): **default = 1280** |br| | ||
Width of the displayed window, in pixels. | ||
window_height (:obj:`int`): **default = 720** |br| | ||
Height of the displayed window, in pixels. | ||
window_x_coord (:obj:`int`): **default = 0** |br| | ||
X-coordinate of the top left corner of the displayed window, with reference | ||
from the top left corner of the screen, in pixels. | ||
window_y_coord (:obj:`int`): **default = 0** |br| | ||
Y-coordinate 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_x_coord, self.window_y_coord) | ||
cv2.resizeWindow(self.window_name, self.window_width, self.window_height) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In line with the suggested There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated accordingly. |
||
|
||
def run(self, inputs: Dict[str, Any]) -> Dict[str, Any]: | ||
"""Show the outputs on your display""" | ||
cv2.imshow("PeekingDuck", inputs["img"]) | ||
|
||
cv2.imshow(self.window_name, inputs["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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest OOP-ing the above with a
window
object:Facilitates future attribute extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of this at first, but thought it would be clunky when users read our RTD page. I'd have to lump all the descriptions under one
Dict
type which can look messy with different descriptions. Also there's a mix ofint
andstr
types that get lost when all are lumped underDict
.Example from
resize
config frominput.live
- I think this is simple enough to be nested though.What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, I could do it this way, which is a good compromise:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resize (Dict)
example also relies on the user to infer thebool
andint
types, so it actually servers to highlight the point made on lost type info.window_
totally, just haveand the code will be
self.height
,self.width
, etc.Since, after all, the
screen
is the display.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried the last suggestion, but the keyword
name
causes anAttributeError: can't set attribute
.In the end I went for the in-between solution, the RTD looks like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, let's go with the in-between solution.
Good reminder that
name
is reserved, for future similar cases, we'll have to usetitle
orlabel
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resizeWindow()
doesn't work for opencv >= 4.5.x, only applyingresize()
to the image works. Unfortunately, it is the opposite case for opencv == 4.1.2.30. To avoid discrepancies in behaviour, in this PR, will go with the solution that works for 4.5.x, and will create another PR to upgrade our openCV version (issue #556).Added a boolean config for resizing window that's consistent with
input.live
andinput.recorded
.