Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Madoshakalaka/whichimg
blazing fast template matching when possible images are all known
https://github.com/Madoshakalaka/whichimg
Last synced: 11 days ago
JSON representation
blazing fast template matching when possible images are all known
- Host: GitHub
- URL: https://github.com/Madoshakalaka/whichimg
- Owner: Madoshakalaka
- License: mit
- Created: 2019-07-01T07:54:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-09T16:05:33.000Z (over 5 years ago)
- Last Synced: 2024-05-01T14:38:04.984Z (7 months ago)
- Language: Python
- Size: 47.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-blazingly-fast - whichimg - blazing fast template matching when possible images are all known (Python)
README
# whichimg
![travis-badge](https://travis-ci.org/Madoshakalaka/whichimg.svg?branch=master)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`
```python
from whichimg import ImageTellerteller = 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.
```python
teller = ImageTeller([img1, img2, img3, img4], surprises=False)
```This is equivalent to the following naive approach
```python
def naive_tell(images, sample_img):
for i, img in enumerate(images):
if np.array_equal(img, sample_img):
return i
return -1naive_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).