-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
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.
Provided some suggestions.
window_height: 720 | ||
window_x_coord: 0 | ||
window_y_coord: 0 |
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:
window: {
name: "PeekingDuck",
x: 0,
y: 0,
width: 1280,
height: 720,
}
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 of int
and str
types that get lost when all are lumped under Dict
.
Example from resize
config from input.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:
window_name: "PeekingDuck"
window_loc: {
x: 0,
y: 0 }
window_size: {
width: 1280,
height: 720 }
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.
- The
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. - The alternative you suggested is a compromise that I am neutral about.
- Another suggestion is to remove
window_
totally, just have
inputs: [...]
outputs: [...]
name: "PeekingDuck"
x: 0
y: 0
width: 1280
height: 720
and 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.
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 use title
or label
.
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 applying resize()
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
and input.recorded
.
""" | ||
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
In line with the suggested window
object above, Node configs will accept a window
object and code will reference its attributes via self.window.name
, etc.
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.
Updated accordingly.
Looks like the issue is caused by the opencv version. I had no issues when using |
opencv for M1 Mac is 4.5.1. Looks like behavioural changes from earlier versions. |
Added issue #556 - I'll raise another PR to update our opencv version to 4.5.x, and the solution in this PR will tackle behaviour for 4.5.x and higher. |
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.
Suggested a minor refactoring.
resized_img = cv2.resize( | ||
inputs["img"], (self.window_size["width"], self.window_size["height"]) | ||
) | ||
cv2.imshow(self.window_name, resized_img) |
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.
Would like to propose streamlining the code segment in lines 55-61 as:
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)
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.
This looks better, updated.
Tested the following scenario (M1 Mac opencv 4.5.1):
The PKD window is now the new size, even though the I suppose this is an "acceptable" behavior? |
Yes, I think this is acceptable. To let users know that this may happen (and that it's an option to manually resize), I added to the |
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.
Updates 👍🏼
closes #543
Summary of improvements: