バイナリ イメージを templateMatch することは可能ですか? 私はそれを試しましたが、何も役に立ちません。私はいつもエラーが発生します:
cv2.error: OpenCV(3.4.5) C:\projects\opencv-python\opencv\modules\imgproc\src\templmatch.cpp:1107: error: (-215:Assertion failed) (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 in function 'cv::matchTemplate'
使用してみましastype(np.uint8)
たが、どちらも役に立ちません。
//template is already binary
//edited: all the code
img = cv2.imread('img/img.png')
template = cv2.imread('template-match/template.png')
img_roi=img[310:1060,510:1430]
img_gray = cv2.cvtColor(img_roi,cv2.COLOR_BGR2GRAY)
afterEnhance = cv2.GaussianBlur(img_gray, (7, 7), 0)
afterEnhance=cv2.equalizeHist(afterEnhance)
_,th1=cv2.threshold(afterEnhance,55,255,cv2.THRESH_BINARY)
result = cv2.matchTemplate(th1, template,cv2.TM_CCOEFF)