资源简介
微信跳一跳外挂实现,原文地址:http://blog.csdn.net/xiangzhihong8/article/details/79140668
代码片段和文件信息
import cv2 as cv
img = cv.imread(“4.png“)
player_template = cv.imread(‘player.png‘)
player = cv.matchTemplate(img player_template cv.TM_CCOEFF_NORMED)
min_val max_val min_loc max_loc = cv.minMaxLoc(player)
corner_loc = (max_loc[0] + 50 max_loc[1] + 150)
player_spot = (max_loc[0] + 25 max_loc[1] + 150)
#绘制player位置标记
cv.rectangle(img max_loc corner_loc (0 0 255) 5)
cv.circle(img player_spot 10 (255 0 0) -1)
img_blur = cv.GaussianBlur(img (5 5) 0) #高斯模糊
canny_img = cv.Canny(img_blur 1 10) #边缘检测
height width = canny_img.shape
#消除多余的头部
for y in range(max_loc[1] max_loc[1]+150):
for x in range(max_loc[0] max_loc[0]+50):
canny_img[y][x] = 0
crop_img = canny_img[300:int(height/2) 0:width] #裁切
crop_h crop_w = crop_img.shape
center_x center_y = 0 0 #临时变量
max_x = 0
#计算中央点
for y in range(crop_h):
for x in range(crop_w):
if crop_img[y x] == 255:
if center_x == 0:
center_x = x
if x > max_x:
center_y = y
max_x = x
cv.circle(crop_img (center_x center_y) 10 255 -1)
block_center = (center_x center_y+300) #中央点
cv.circle(img block_center 10 255 -1) #绘制落脚点
cv.line(img player_spot block_center (0 255 0) 5) #绘制直线
print(“玩家位置“ player_spot)
print(“落点位置“ (center_x center_y+300))
cv.namedWindow(‘img‘ cv.WINDOW_KEEPRATIO)
cv.imshow(“img“ img)
cv.waitKey(0)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-01-21 22:37 OpenCV_Wechat_jump-master\
目录 0 2018-01-21 22:37 OpenCV_Wechat_jump-master\.idea\
文件 589 2018-01-21 22:37 OpenCV_Wechat_jump-master\.idea\Wechat_jump.iml
文件 199 2018-01-21 22:37 OpenCV_Wechat_jump-master\.idea\misc.xm
文件 274 2018-01-21 22:37 OpenCV_Wechat_jump-master\.idea\modules.xm
文件 233 2018-01-21 22:37 OpenCV_Wechat_jump-master\.idea\other.xm
文件 180 2018-01-21 22:37 OpenCV_Wechat_jump-master\.idea\vcs.xm
文件 48152 2018-01-21 22:37 OpenCV_Wechat_jump-master\1.png
文件 63536 2018-01-21 22:37 OpenCV_Wechat_jump-master\2.png
文件 61327 2018-01-21 22:37 OpenCV_Wechat_jump-master\3.png
文件 61729 2018-01-21 22:37 OpenCV_Wechat_jump-master\4.png
文件 22 2018-01-21 22:37 OpenCV_Wechat_jump-master\README.md
文件 1522 2018-01-21 22:37 OpenCV_Wechat_jump-master\play.py
文件 8701 2018-01-21 22:37 OpenCV_Wechat_jump-master\pla
文件 279616 2018-01-21 22:37 OpenCV_Wechat_jump-master\test.png
- 上一篇:设计模式课后习题源代码
- 下一篇:画跟踪精确度图的程序.zip
评论
共有 条评论