Beispiel #1
0
    def train_template(self, template=False) -> bool:
        # template = False
        if template:
            img1 = cv2.imread('./screenshot/jia_guo_meng.png')[1855:1920,
                                                               625:695]  # 1
            img2 = cv2.imread('./screenshot/jia_guo_meng.png')[1770:1850,
                                                               785:850]  # 2
            img3 = cv2.imread('./screenshot/jia_guo_meng.png')[1715:1750,
                                                               935:980]  # 3
            cv2.imwrite('./template/jiaguomeng/1.png', img1)
            cv2.imwrite('./template/jiaguomeng/2.png', img2)
            cv2.imwrite('./template/jiaguomeng/3.png', img3)
            return

        png_file: str = Adb.screen_shot(self.__png_name,
                                        self.__screenshot_path)
        img = cv2.imread(png_file)
        for house in self.__houses:
            center: tuple = self.__find_center(img, house)
            if center:
                Adb.swipe(center[0], center[1], self.__pos[house][0],
                          self.__pos[house][1], 250)
                return True
        return False
Beispiel #2
0
 def update(self, milli):
     Adb.swipe(900, 2150, 900, 2150, milli)
     Adb.screen_shot(self.__png_name, self.__screenshot_path)