Fix match template
|
Before Width: | Height: | Size: 1010 B |
|
Before Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 8.1 MiB |
|
Before Width: | Height: | Size: 4.0 MiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 815 KiB |
@@ -1,14 +1,11 @@
|
||||
import os
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
# interpolate here_path to get the path to the fishing target image
|
||||
herePath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
img = cv.imread(os.path.join(herePath, "assets", "Bobber2.png"), cv.IMREAD_GRAYSCALE)
|
||||
img = cv.imread('screen.jpg', cv.IMREAD_GRAYSCALE)
|
||||
assert img is not None, "file could not be read, check with os.path.exists()"
|
||||
img2 = img.copy()
|
||||
template = cv.imread(os.path.join(herePath, "assets", "FishTest3.png"), cv.IMREAD_GRAYSCALE)
|
||||
template = cv.imread('bobber.jpg', cv.IMREAD_GRAYSCALE)
|
||||
assert template is not None, "file could not be read, check with os.path.exists()"
|
||||
w, h = template.shape[::-1]
|
||||
|
||||
@@ -33,16 +30,10 @@ for meth in methods:
|
||||
|
||||
cv.rectangle(img,top_left, bottom_right, 255, 2)
|
||||
|
||||
plt.subplot(121)
|
||||
plt.imshow(res,cmap = 'gray')
|
||||
plt.title('Matching Result')
|
||||
plt.xticks([])
|
||||
plt.yticks([])
|
||||
plt.subplot(122)
|
||||
plt.imshow(img,cmap = 'gray')
|
||||
plt.title('Detected Point')
|
||||
plt.xticks([])
|
||||
plt.yticks([])
|
||||
plt.subplot(121),plt.imshow(res,cmap = 'gray')
|
||||
plt.title('Matching Result'), plt.xticks([]), plt.yticks([])
|
||||
plt.subplot(122),plt.imshow(img,cmap = 'gray')
|
||||
plt.title('Detected Point'), plt.xticks([]), plt.yticks([])
|
||||
plt.suptitle(meth)
|
||||
|
||||
plt.show()
|
||||