Skip to content

Commit 3a06ae2

Browse files
committed
docstring and code format
1 parent b7c191a commit 3a06ae2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

MTM/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def _findLocalMin_(corrMap, score_threshold=0.4):
4848
def computeScoreMap(template, image, method=cv2.TM_CCOEFF_NORMED, mask=None):
4949
"""
5050
Compute score map provided numpy array for template and image (automatically converts images if necessary).
51+
The template must be smaller or as large as the image.
5152
A mask can be provided to limit the comparison of the pixel values to a fraction of the template region.
5253
The mask should have the same dimensions and image type than the template.
5354
@@ -85,7 +86,8 @@ def computeScoreMap(template, image, method=cv2.TM_CCOEFF_NORMED, mask=None):
8586

8687
def findMatches(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=float("inf"), score_threshold=0.5, searchBox=None):
8788
"""
88-
Find all possible templates locations provided a list of templates to search and an image.
89+
Find all possible templates locations satisfying the score threshold provided a list of templates to search and an image.
90+
Returns a pandas dataframe with one row per detection.
8991
9092
Parameters
9193
----------
@@ -107,7 +109,7 @@ def findMatches(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=floa
107109
- score_threshold: float in range [0,1]
108110
if N_object>1, returns local minima/maxima respectively below/above the score_threshold
109111
110-
- searchBox : tuple (X, Y, Width, Height) in pixel unit
112+
- searchBox : tuple (x, y, width, height) in pixel unit
111113
optional rectangular search region as a tuple
112114
113115
Returns
@@ -120,7 +122,8 @@ def findMatches(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=floa
120122
## Crop image to search region if provided
121123
if searchBox is not None:
122124
xOffset, yOffset, searchWidth, searchHeight = searchBox
123-
image = image[yOffset:yOffset+searchHeight, xOffset:xOffset+searchWidth]
125+
image = image[yOffset : yOffset+searchHeight, xOffset : xOffset+searchWidth]
126+
124127
else:
125128
xOffset=yOffset=0
126129

@@ -133,7 +136,7 @@ def findMatches(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=floa
133136
templateName, template = tempTuple[:2]
134137
mask = None
135138

136-
if len(tempTuple)>=3:
139+
if len(tempTuple)>=3: # ie a mask is also provided
137140
if method in (0,3):
138141
mask = tempTuple[2]
139142
else:

0 commit comments

Comments
 (0)