QQ游戏连连看自动化脚本(仅限学习交流)
最近看到了一份连连看的自动化脚本,对其中的图像识别挺感兴趣就研究了一番
import random
import time
import cv2
import numpy as np
import win32api
import win32con
import win32gui
from PIL import ImageGrab
from ImageSimilarityDegree import classify_gray_hist
# x轴 块数量
x_num = 19
# y轴 块数量
y_num = 11
img_list = []
linkup_blocks = np.zeros((y_num, x_num))
TIME_INTERVAL_MIN = 0.1
TIME_INTERVAL_MAX = 0.3
POINT_WIDTH = 31
POINT_HEIGHT = 35
game_x = 14
game_y = 180
# 图片裁切
# w 800 h 600 top 180 block_w=30 block_h=32
def init_img(image_path):
full_image = cv2.imread(image_path)
crop_width = POINT_WIDTH
crop_height = POINT_HEIGHT
bg_img = cv2.imread('bg.png')
for i in range(11):
for j in range(19):
# 裁切每一块区域
cropped = full_image[180 + crop_height * i:180 + crop_height * (i + 1),
14 + crop_width * j: