打开CV2图像识别

时间:2013-07-20 20:26:56

标签: python opencv

我正在尝试学习OpenCV for python, 我用Google搜索了几个代码示例并将几个代码示例添加到一起并提出了这个:

import cv2
import time
import numpy as np
c = cv2.VideoCapture(0)
def desp():
    _ , f = c.read()
    res = cv2.matchTemplate(f,tem,cv2.TM_CCOEFF_NORMED)
    pnt = np.unravel_index(res.argmax(),res.shape)  
    cv2.rectangle(f,(pnt[0]+50,pnt[1]+50),pnt,255)
    cv2.imshow('example',f)
    cv2.waitKey(1)

tem = cv2.imread(r"C:\Users\<my user>\Pictures\findMe.jpg")
otm = time.time()
while otm + 40 > time.time():
    desp()

由于某种原因,未在图像周围绘制矩形

0 个答案:

没有答案