Skip to content

Conversation

@hakim-cherif-mchp
Copy link

While working with code samples from this repository, I have seen that some parts are not optimized in time, and on some hardware the difference is significant.

On the Microchip SAMA7G54 is was able to divide by 25 the time taken for these operations. (From 500 ms to 20ms).

… INTER_NEAREST is much quicker on hardware not equipped with image processing IPs.
@AIWintermuteAI AIWintermuteAI added the enhancement New feature or request label Oct 24, 2024
@AIWintermuteAI
Copy link
Contributor

@Alex-EEE can you take a look?

Copy link
Collaborator

@Alex-EEE Alex-EEE left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! The efficiency gains make a lot of sense, as you've converted a lot of this to numpy manipulations instead of slow lists

There's at least one bug to address, did you try running this code?

We'll also test and get back

resize_size = (resize_size_w, resize_size_h)

resized = cv2.resize(img, resize_size, interpolation=cv2.INTER_AREA)
resized = cv2.resize(img, resize_size, interpolation=cv2.INTER_NEAREST)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We feel Inter Area is the best trade off for performance and output, especially since the user should only be downsizing. But I'm open to hear your thoughts

Copy link
Author

Choose a reason for hiding this comment

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

Hi Alex,
Sorry for the delay, I tested more extensively the two algorithms, and it appears that it is possible to get a very high similarity score between the two sets of extracted features, but only under certain circumstances.
So, in my opinion, you should keep the INTER_AREA.

if is_grayscale:
resized_img = cv2.cvtColor(resized_img, cv2.COLOR_BGR2GRAY)
pixels = np.array(resized_img).flatten().tolist()
if self.isGrayscale:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Although this looks like a member function, it's actually outside of the class and thus there's no self variable

Copy link
Author

Choose a reason for hiding this comment

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

Hi,
My mistake, I corrected it and pushed the related commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants