python图片匹配

#方法一,可以直接用
import pyautogui,time

class Pic():
    def __init__(self):
        pass

        self.w,self.h = pyautogui.size()

    def get_win(self,number_x=32,number_y=24):
        #读取页面,记录rgb数据
        tx = int(self.w/number_x)
        ty = int(self.h/number_y)
        img = pyautogui.screenshot()
        with open("remake.csv", "w", encoding="utf-8") as f:
            for x in range(number_x-1):
                for y in range(number_y-1):
                    lx = (x + 1) * tx
                    ly = (y + 1) * ty
                    r,g,b = img.getpixel((lx,ly))
                    f.write("{},{},{},{},{},\n".format(lx,ly,r,g,b))
                    f.flush()

    def _read_win(self,lis):
        #传入坐标,rpg数据判断当前页面是否匹配
        count = len(lis)
        start_time = time.time()
        while self.reading:
            count_get = 0
            print("正在匹配 = ing&#

你可能感兴趣的:(python,python)