我正在尝试使用 Python 制作虹膜扫描仪并打开 CV。使用模板匹配功能时出现以下错误:
import cv2
import numpy as np
img1 = cv2.imread('canny.jpg');
img2 = cv2.imread('frame1.jpg');
edges=cv2.Canny(img2,100,100)
w,h=edges.shape[::-1]
res = cv2.matchTemplate(img1 , edges, cv2.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where(res >= threshold)
print loc
以下是错误:
Traceback (most recent call last):
File "E:/OpenCV Programs/threshold2img1.py", line 9, in <module>
res = cv2.matchTemplate(img1 , edges, cv2.TM_CCOEFF_NORMED)
error: OpenCV(3.4.1) C:\build\master_winpack-bindings-win32-vc14-static\opencv\modules\imgproc\src\templmatch.cpp:1102: error: (-215) (depth == 0 || depth == 5) && type == _templ.type() && _img.dims() <= 2 in function cv::matchTemplate