Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I am trying to write a python script to analyze many still images that have different logos in them
The logo is not always of a fixed size and clarity is not the same either
(the logo's resolution in the image could be good or bad - it varies and size roughly changes too)

The script I have written so far uses a multiscale template matching method (opencv library)
(inspired by -
It accounts for only one template at a time and gives higher accuracy using a low resolution template

Since thresholding doesn't work I tried setting a region where the logo was more likely to appear;
And save the image if a logo match was found in that area.
This doesn't always work because sometimes it matches similar logos or marks that area even when it couldn't find any logos.

Could you please advise on how to use maxVal as an indicator of similarity for the multiscale template matching method? Which measure of similarity would you recommend to ascertain that the multiscale template matching method return a valid result?

I could use any suggestions or methods to improve on the script



Script(Code): Dropbox -[^]

To run the script, arguments have to be supplied in powershell or command prompt [cmd] (in the following way):
a)python --template /.../.../.../[Name].[EXT] --images /.../.../...
python --template /Users/myusername/Pictures/LogoFolder/mylogo.png --images /Users/myusername/Pictures/StillImageFolder
b)python --template /.../.../.../[Name].[EXT] --images /.../.../... --visualize 1
python --template /Users/myusername/Pictures/LogoFolder/mylogo.png --images /Users/myusername/Pictures/StillImageFolder --visualize 1

I added some code (towards the end) to automate the script so the user does not have to manually close every window with the resulting match for all images.
The window shows the match result for 10 seconds and then moves to the next image.

What I have tried:

I tried using thresholds (using value returned from matchTemplate function) and also tried using the maxVal as an indicator of similarity but I keep getting really huge bizarre values (for those variables)
I compared the values over different screenshot matches and I can't seem to be able find a correlation/pattern

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900