- 
                Notifications
    You must be signed in to change notification settings 
- Fork 28
Optimize in time the image feature extractions algorithms #23
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
base: master
Are you sure you want to change the base?
Optimize in time the image feature extractions algorithms #23
Conversation
… INTER_NEAREST is much quicker on hardware not equipped with image processing IPs.
…on some hardware platforms.
| @Alex-EEE can you take a look? | 
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.
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) | 
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.
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
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.
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.
        
          
                edge_impulse_linux/image.py
              
                Outdated
          
        
      | if is_grayscale: | ||
| resized_img = cv2.cvtColor(resized_img, cv2.COLOR_BGR2GRAY) | ||
| pixels = np.array(resized_img).flatten().tolist() | ||
| if self.isGrayscale: | 
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.
Although this looks like a member function, it's actually outside of the class and thus there's no self variable
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.
Hi,
My mistake, I corrected it and pushed the related commit.
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).