简体   繁体   中英

Template matching results when the template is not on the original image

For testing purposes I'm building a bot that clicks on buttons in the screen. I have a folder with all the possible buttons that needs to be pressed and the application being tested only has one button shown at a time. There is no situations where two or more buttons appear together on the screen.

My approach is to take a screenshot every few seconds and loop through all the possible buttons and try to find them on the screenshot. If the button is found the bot clicks the center of the button.

My issue is that even if the button is not present on the screenshot the template algorithm I'm using returns a false positive somewhere in the screen. Is there any way to make sure no false positives are returned unless the button exists on the image?

I'm using python with numpy and skimage. For the template matching I'm using skimage.feature.match_template.

I already tried with opencv using SIFT and all those things with not much success and a lot of issues with opencv itself.

PS: If you think there is a better way to solve the problem itself (testing an app by pressing buttons) they are welcome too.

Cheers

Edit 1:

These are the images:

截图按键

Edit 2:

The output of the script (false positive) 在此处输入图片说明

正如我稍后意识到的那样,确保检测到的图像确实是您要搜索的图像的唯一方法是计算检测到的图像与模板之间的差异,并使用阈值来考虑缺陷。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM