Skip to content

Commit b542e3f

Browse files
committed
Move test to separate script
1 parent b1156be commit b542e3f

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

MTM/__init__.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -238,27 +238,4 @@ def drawBoxesOnGray(image, tableHit, boxThickness=2, boxColor=255, showLabel=Fal
238238
cv2.rectangle(outImage, (x, y), (x+w, y+h), color=boxColor, thickness=boxThickness)
239239
if showLabel: cv2.putText(outImage, text=row['TemplateName'], org=(x, y), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=labelScale, color=labelColor, lineType=cv2.LINE_AA)
240240

241-
return outImage
242-
243-
244-
if __name__ == '__main__':
245-
from skimage.data import coins
246-
import matplotlib.pyplot as plt
247-
248-
## Get image and templates by cropping
249-
smallCoin = coins()[37:37+38, 80:80+41]
250-
bigCoin = coins()[14:14+59,302:302+65]
251-
image = coins()
252-
253-
## Perform matching
254-
#tableHit = matchTemplates([('small', smallCoin), ('big', bigCoin)], image, score_threshold=0.6, method=cv2.TM_CCOEFF_NORMED, maxOverlap=0) # Correlation-score
255-
tableHit = matchTemplates([('small', smallCoin), ('big', bigCoin)], image, score_threshold=0.4, method=cv2.TM_SQDIFF_NORMED, maxOverlap=0) # Difference-score
256-
257-
print("Found {} coins".format(len(tableHit)))
258-
259-
print(tableHit)
260-
261-
262-
## Display matches
263-
Overlay = drawBoxesOnRGB(image, tableHit, showLabel=True)
264-
plt.imshow(Overlay)
241+
return outImage

test.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from skimage.data import coins
2+
import matplotlib.pyplot as plt
3+
import MTM, cv2
4+
5+
## Get image and templates by cropping
6+
smallCoin = coins()[37:37+38, 80:80+41]
7+
bigCoin = coins()[14:14+59,302:302+65]
8+
image = coins()
9+
10+
## Perform matching
11+
#tableHit = MTM.matchTemplates([('small', smallCoin), ('big', bigCoin)], image, score_threshold=0.6, method=cv2.TM_CCOEFF_NORMED, maxOverlap=0) # Correlation-score
12+
tableHit = MTM.matchTemplates([('small', smallCoin), ('big', bigCoin)], image, score_threshold=0.4, method=cv2.TM_SQDIFF_NORMED, maxOverlap=0) # Difference-score
13+
14+
print("Found {} coins".format(len(tableHit)))
15+
16+
print(tableHit)
17+
18+
19+
## Display matches
20+
Overlay = MTM.drawBoxesOnRGB(image, tableHit, showLabel=True)
21+
plt.imshow(Overlay)

0 commit comments

Comments
 (0)