-
Notifications
You must be signed in to change notification settings - Fork 0
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
Returning frames as PIL images #37
base: main
Are you sure you want to change the base?
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.
The more I think about this the more I think we need to do this in a backwards compatible way. I think instead we just offer a grabimg()
method which returns a PIL image. Too much stuff would break.
To deprecate, I think the best way is to update the docs - aren't there any in here we should update for this? Or are they all in the SDK?
We could more aggressively deprecate - keep the _grab_impl
method (maybe call it _grab_np
instead?) and have the grab()
method issue a warning saying "please switch to grab_img instead" but I don't know that really does much except annoy us.
Sure, I can update the docs. Should we log a warning when someone uses |
I think we just offer two, and recommend the PIL image as being simple and more reliable. |
|
||
cv2.destroyAllWindows() | ||
for camera_name, grabber in grabbers.items(): | ||
frame = grabber.grabimg() |
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.
updating to use grabimg
as that is our preferred method
@@ -13,15 +11,8 @@ | |||
|
|||
grabber = FrameGrabber.create_grabber(config) | |||
|
|||
while True: | |||
frame = grabber.grab() | |||
frame = grabber.grabimg() |
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.
changing to grabimg
again
Previously, FrameGrab has always returned numpy arrays. This PR changes FrameGrab to return PIL images instead.
numpy arrays can be challenging because they don't contain any metadata about color space, and therefore it's easy to mix up RGB and BGR. PIL images contain a
mode
attribute that fixes this usability problem.We believe users will appreciate receiving PIL images. If they need a numpy array, they can easily convert.
This will be a breaking change, and I'm not sure if there is a way to avoid this. We could leave the old
grab
method the way it is, returning numpy arrays, and then create a new method calledgrab_frame
(or something similar) that returns PIL images, but I don't believe this works towards our ultimate goal of deprecating numpy images; people will gravitate towardsgrab
because it's simpler and probably the first thing autocomplete serves them. Maybe we could log a warning when people usegrab
and deprecate it in the future? However this leaves us withgrab_frame
as our main method, which is not as elegant as justgrab
.