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

asked 2016-09-27 03:49:37 -0500

timothywgreen gravatar image

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/...) 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/5ipfiw39han...

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.

edit retag flag offensive close merge delete

Comments

Are you using the _NORMED template matching types? I think that restricts the value to between 0 and 1 whereas the other types do not. It's been a while since I've looked at that, and I ended up altering it myself for a specific task.

Also some methods (SQDIFF?) use 0 as correct instead of 1.

Tetragramm gravatar imageTetragramm ( 2016-09-27 07:45:12 -0500 )edit