Merge pull request #25805 from TFiFiE:patch-1

Replace use of "eval()" with "getattr()".
This commit is contained in:
Alexander Smorkalov 2024-06-25 13:26:28 +03:00 committed by GitHub
commit 76a1d26bcd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -46,12 +46,12 @@ assert template is not None, "file could not be read, check with os.path.exists(
w, h = template.shape[::-1]
# All the 6 methods for comparison in a list
methods = ['cv.TM_CCOEFF', 'cv.TM_CCOEFF_NORMED', 'cv.TM_CCORR',
'cv.TM_CCORR_NORMED', 'cv.TM_SQDIFF', 'cv.TM_SQDIFF_NORMED']
methods = ['TM_CCOEFF', 'TM_CCOEFF_NORMED', 'TM_CCORR',
'TM_CCORR_NORMED', 'TM_SQDIFF', 'TM_SQDIFF_NORMED']
for meth in methods:
img = img2.copy()
method = eval(meth)
method = getattr(cv, meth)
# Apply template Matching
res = cv.matchTemplate(img,template,method)