-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Closed
Labels
category: documentationDocumentation fix or updateDocumentation fix or update
Milestone
Description
Describe the doc issue
The sample program at https://docs.opencv.org/5.0.0-alpha/de/da9/tutorial_template_matching.html draws the wrong rectangle on the image, reversing the width and height. The problem is that it adds shape[0] to the first (X) coordinate and shape[1] to the second (Y) coordinate, but numpy.shape has the height first and the width second, the opposite order.
Fix suggestion
The problem is in the demo program at https://github.com/opencv/opencv/blob/5.x/samples/python/tutorial_code/imgProc/match_template/match_template.py
cv.rectangle(img_display, matchLoc, (matchLoc[0] + templ.shape[0], matchLoc[1] + templ.shape[1]), (0,0,0), 2, 8, 0 )
cv.rectangle(result, matchLoc, (matchLoc[0] + templ.shape[0], matchLoc[1] + templ.shape[1]), (0,0,0), 2, 8, 0 )
should change to
cv.rectangle(img_display, matchLoc, (matchLoc[0] + templ.shape[1], matchLoc[1] + templ.shape[0]), (0,0,0), 2, 8, 0 )
cv.rectangle(result, matchLoc, (matchLoc[0] + templ.shape[1], matchLoc[1] + templ.shape[0]), (0,0,0), 2, 8, 0 )
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
category: documentationDocumentation fix or updateDocumentation fix or update