blazing fast template matching when possible images are all known. Good for GUI scripting.
Project description
whichimg
blazing fast template matching when possible images are all known. Handy tool for GUI scripting.
How to Use
It supports python 3.6 +
pip install whichimg
from whichimg import ImageTeller
teller = ImageTeller([img1, img2, img3, img4]) # numpy arrays
teller.tell(secret_img) # returns 0 or 1 or 2 or 3 or -1 for not found
if you're sure secret_img
is one of the images, you can set keyword argument surprises
to False
. This will give you a minor performance gain.
teller = ImageTeller([img1, img2, img3, img4], surprises=False)
This is equivalent to the following naive approach
def naive_tell(images, sample_img):
for i, img in enumerate(images):
if np.array_equal(img, sample_img):
return i
return -1
naive_tell([img1, img2, img3, img4], secret_img)
Note
It's not generally faster than the naive approach. I thought my approach was faster and spent a week writing this shit though. lmfao.
They're about equally fast on the tests/fixtures
testing data I came up with (10x10 images). Through my rough testing, there could be a magnitude of performance gain when there are many possible images (>10) and when the images are larger (200x200 for example).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file whichimg-1.0.5.tar.gz
.
File metadata
- Download URL: whichimg-1.0.5.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05453cb5207b953b434c0db51852e7fba7dfaf5e4b79f2ffe1f43d54f477f8bc |
|
MD5 | 7f8dcf6de1e1027583638b211a726722 |
|
BLAKE2b-256 | 1f8df66e437b8c59fc5a2a96148363380069f75938a873c7221d4725fa0ed75f |