Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I solve this issue for this Multiscale Template Matching script?

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

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

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): https://www.dropbox.com/s/5ipfiw39hanbhjc/code.py?dl=0

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.