Note the error message:
error: (-215) (depth == CV_8U || depth == CV_32F) && & & type == _templ.type () && & _img.dims () <= 2 in the cv :: matchTemplate function
This means that the image data type must be CV_8U or CV_32F, and it must have 3 or less channels.
If you do not know what CV_8U, CV_32F means, see this list .
Perhaps you are passing numpy objects other than np.uint8 or np.float32. you can easily convert numpy dtype to 8-bit or 32-bit using:
img.astype(np.float32) img.astype(np.uint8)
Just note that OpenCV expects 8-bit CV_8U data to be in the range 0..255, and CV_32F can be in any range.
Elad joseph
source share