看一下下面的代码。
import cv
import cv2
print "starting now"
im = cv.CaptureFromCAM(0)
template=cv.LoadImage("/home/patrick/Desktop/card.JPG")
W=3648
H=2736
w,h = cv.GetSize(template)
width = W - w + 1
height = H - h + 1
result = cv.CreateImage((width, height), 32, 1)
#image= cv.CreateImage((width, height), 32, 1)
cv.MatchTemplate(im, template, result, cv.CV_TM_CCORR)
(min_x, max_y, minloc, maxloc) = cv.MinMaxLoc(result)
(x, y) = minloc
print (x,y)
当我运行时,我得到以下错误信息
cv.MatchTemplate(im, template, result, cv.CV_TM_CCORR)
TypeError: CvArr argument 'image' must be IplImage, CvMat or CvMatND. Use fromarray() to convert numpy arrays to CvMat or cvMatND
如何将网络摄像头中的图像转换为可以使用匹配模板处理的数据?
最佳答案
关于python - 使用opencv与网络摄像机匹配的模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19202312/