Skip to content

Conversation

@robotrapta
Copy link
Member

@robotrapta robotrapta commented Apr 1, 2023

You can now submit imagequeries with PIL images. But obviously only if PIL is installed. Fixes #22

Also you can set gl.DEFAULT_WAIT which overrides the default 30 for all submit-image-query calls.

@robotrapta robotrapta changed the title Pil image support - Fixes #22 Pil image support. Default WAIT Apr 1, 2023
@robotrapta robotrapta requested a review from tyler-romero April 1, 2023 17:22
@robotrapta robotrapta marked this pull request as ready for review April 1, 2023 17:23
Copy link

@obj-imp obj-imp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the ndarray type detection work if you pass an OpenCV frame or do you have to cast it ?

def submit_image_query(
self,
detector: Union[Detector, str],
image: Union[str, bytes, BytesIO, BufferedReader, np.ndarray],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add Image.Image to the supported input types

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Contributor

@tyler-romero tyler-romero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple nits

@robotrapta
Copy link
Member Author

does the ndarray type detection work if you pass an OpenCV frame or do you have to cast it ?

Unfortunately, I think the answer is that it "almost works". I think what will happen is that we will accept the image, but the colors will be wrong because OpenCV uses BGR order for color-channel, but we expect RGB.

This is certainly not awesome. If we're getting an image as a numpy array, it's very likely it came from OpenCV. Maybe we should require images to be BGR. That change would be backwards incompatible though. Filed #34 to track this.

@robotrapta robotrapta merged commit 74872b7 into main Apr 3, 2023
@robotrapta robotrapta deleted the pil-image-support branch April 3, 2023 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to send PIL image directly

4 participants