Skip to content

Commit 80d765c

Browse files
authored
Add function doc
1 parent a7f24b3 commit 80d765c

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,76 @@ Using pip, `pip install Multi-Template-Matching`
88
Once installed, `import MTM`should work.
99

1010
# Documentation
11+
The package NMS contains mostly 2 important functions:
12+
13+
## matchTemplate
14+
`matchTemplates(listTemplates, image, method=cv2.TM_CCOEFF_NORMED, N_object=float("inf"), score_threshold=0.5, maxOverlap=0.25, searchBox=None)`
15+
16+
This function searches each template in the image, and return the best N_object location which offer the best scores and which do not overlap above the `maxOverlap` threshold.
17+
18+
__Parameters__
19+
- _listTemplates_:
20+
list of tuples (LabelString, Grayscale or RGB numpy array) templates to search in each image, associated to a label
21+
22+
- _image_ : Grayscale or RGB numpy array
23+
image in which to perform the search, it should be the same bitDepth and number of channels than the templates
24+
25+
- _method_ : int
26+
one of OpenCV template matching method (0 to 5), default 5=0-mean cross-correlation
27+
28+
- _N_object_: int
29+
expected number of objects in the image
30+
31+
- score_threshold: float in range [0,1]
32+
if N>1, returns local minima/maxima respectively below/above the score_threshold
33+
34+
- _maxOverlap_: float in range [0,1]
35+
This is the maximal value for the ratio of the Intersection Over Union (IoU) area between a pair of bounding boxes.
36+
If the ratio is over the maxOverlap, the lower score bounding box is discarded.
37+
38+
- _searchBox_ : tuple (X, Y, Width, Height) in pixel unit
39+
optional rectangular search region as a tuple
40+
41+
__Returns__
42+
- _bestHits_:list of match as dictionaries {"TemplateName":string, "BBox":(X, Y, Width, Height), "Score":float}
43+
if N=1, return the best matches independently of the score_threshold
44+
if N<inf, returns up to N best matches that passed the score_threshold
45+
if N=inf, returns all matches that passed the score_threshold
46+
47+
48+
The function `findMatches` performs the same detection without the Non-Maxima Supression.
49+
50+
## drawBoxes
51+
The 2nd important function is `drawBoxes` to display the detections as rectangular bounding boxes on the initial image.
52+
`drawBoxes(image, listHit, boxThickness=2, boxColor=(255, 255, 00), showLabel=True, labelColor=(255, 255, 0)`
53+
54+
This function returns a copy of the image with predicted template locations as bounding boxes overlaid on the image
55+
The name of the template can also be displayed on top of the bounding boxes with showLabel=True.
56+
57+
__Parameters__
58+
- _image_ : numpy array
59+
image in which the search was performed
60+
61+
- _listHit_ :
62+
list of hit as returned by matchTemplates or findMatches
63+
64+
- _boxThickness_: int
65+
thickness of bounding box contour in pixels
66+
67+
- _boxColor_: (int, int, int)
68+
RGB color for the bounding box
69+
70+
- _showLabel_: Boolean
71+
Display label of the bounding box (field TemplateName)
72+
73+
- _labelColor_: (int, int, int)
74+
RGB color for the label
75+
76+
__Returns__
77+
- _outImage_: RGB image
78+
original image with predicted template locations depicted as bounding boxes
79+
80+
# Examples
1181
Check out the [jupyter notebook tutorial](https://github.com/LauLauThom/Multi-Template-Matching/blob/master/Tutorial.ipynb) for some example of how to use the package.
1282
The [wiki](https://github.com/LauLauThom/MultiTemplateMatching/wiki) section of this related repository also provides some information about the implementation.
1383

0 commit comments

Comments
 (0)