安装依赖
1)下载安装opencv-2.4.9,并将cv2.pyd拷贝到python安装目录的site-package下
2)pip install numpy
3)pip install aircv
准备一张原图和截图
原图
截图
代码
import cv2
import aircv as ac
def draw_circle(img, pos, circle_radius, color, line_width):
cv2.circle(img, pos, circle_radius, color, line_width)
cv2.imshow('objDetect', imsrc)
cv2.waitKey(0)
cv2.destroyAllWindows()
if __name__ == "__main__":
imsrc = ac.imread('bg.jpg')
imobj = ac.imread('obj.png')
pos = ac.find_template(imsrc, imobj)
circle_center_pos = pos['result']
circle_radius = 50
color = (0, 255, 0)
line_width = 10
draw_circle(imsrc, circle_center_pos, circle_radius, color, line_width)
效果图