Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Feature: transparent pixels #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

BrettMoan
Copy link

For a personal project, i wanted to use pyautogui that uses pyscreeze as a dependancy.

I needed to do template matching with images that have an alpha channel, where the background is meant to be "transparent". as i dug into the code i realized this has been requested in the past but no one worked on it, so i decided to get it working locally in my copy of pyscreeze before submitting this pull request.

this is actually my first attempt in playing with computer vision, so I did a lot of googling and fiddling with this stackoverflow answer to which I credit most of the logic.

BrettMoan added 2 commits May 31, 2020 01:36
When using opencv as the `locateall` function, adds three additional keywords `alpha` and `method`, and `hardedge`

when `alpha` is set to true, `method` must be set to either  cv2.TM_SQDIFF and cv2.TM_CCORR_NORMED, otherwise opencv will end up raising a "not implemented error"

additionally, `hardedge`  can be set to `False`, to not "expand" the transparency. by default the image will be "crop" any alpha less than or equal to 128 to transparent, and any alpha above 128 will be considered non-transparent
Adds support for matchTemplate with transparency
@BrettMoan
Copy link
Author

@asweigart lmk if you have any interest in this functionality or not. Id be willing to throw in some tests as well, if you have any images you think would be good canidates to test effectiveness. I don't have much experience in this field so idk what pictures to choose.

@TSTsankov
Copy link

Thums up for that

@Avasam
Copy link

Avasam commented Aug 21, 2024

@BrettMoan This now has conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants