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

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 - http://www.pyimagesearch.com/2015/01/26/multi-scale-template-matching-using-python-opencv/)
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

Thanks!

P.S.

Script(Code): Dropbox - code.py[^]

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

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