Esempio n. 1
0
def prepare_calibrate_dir(name):
    image_dir = 'calibrate_distance/image_match_dir/' + name + '/'
    for i in range(0, 20):
        if not os.path.exists(image_dir + str(i)):
            image_dir += str(i) + '/'
            break
    os.makedirs(image_dir, exist_ok=True)
    win32_cap(filename=image_dir + '4444.png', rect=(100, 100, 400, 1600))
    return image_dir
    def tab_func(self):
        screen = win32_cap(
            'D:/github_project/auto_press_down_gun/temp_image/auto_screen_capture.png'
        )
        if 'in' == self.in_tab_detect.diff_sum_classify(
                crop_screen(screen, sc_pos['in_tab'])):
            n = 0
            name_crop = crop_screen(screen, sc_pos['weapon1name'])
            scope_crop = crop_screen(screen, sc_pos['weapon1scope'])
            self.all_states.weapon[
                n].name = self.name_detect.diff_sum_classify(name_crop)
            self.all_states.weapon[
                n].scope = self.scope_detect.diff_sum_classify(
                    scope_crop, absent_return="1")

            self.hole_counter = 0
    def cap_screens(self):
        save_fold = os.path.join(self.save_root,
                                 self.all_states.weapon[0].name)
        os.makedirs(save_fold, exist_ok=True)

        r_x0, r_y0, r_x1, r_y1 = 1520, 250, 1920, 1150
        self.hole_counter = 0
        while True:
            im = win32_cap(
                self.all_states.weapon[0].name + '/' + str(self.hole_counter) +
                '.png', (r_x0, r_y0, r_x1, r_y1))
            time.sleep(0.1)

            hole_centers = find_bullet_hole(im)
            if len(hole_centers) < 2:
                break
            x1 = hole_centers[-2][0] + r_x0
            y1 = hole_centers[-2][1] + r_y0
            move_screen_center_to(x1, y1 - (r_y1 - r_y0) // 2 + 30)
            time.sleep(0.1)

            self.hole_counter += 1
Esempio n. 4
0
    def on_press(self, key):
        if key == keyboard.Key.ctrl_l and self.is_calibrating:
            n = self.all_states.weapon_n
            name = self.all_states.weapon[n].name
            self.image_dir = prepare_calibrate_dir(name)

        if key == keyboard.Key.tab:
            self.screen = win32_cap()
            threading.Timer(0.3, self.is_in_tab).start()
        if key == keyboard.Key.f12:
            self.all_states.dont_press = True

        if hasattr(key, 'char'):
            key = key.char
        if key == 'g' or key == '5':
            self.all_states.dont_press = True
        if key == 'b':
            self.all_states.dont_press = False
            threading.Timer(0.5, self.set_fire_mode).start()
        if key == '1' or key == '2':
            self.all_states.dont_press = False
            self.all_states.set_weapon_n(int(key) - 1)
            threading.Timer(0.5, self.set_fire_mode).start()
Esempio n. 5
0
 def task_func(self, idx):
     if self._loop and self.image_dir:
         win32_cap(filename=self.image_dir + str(idx) + '.png',
                   rect=(100, 100, 400, 1600))
Esempio n. 6
0
def get_screen(name=None):
    if name is None:
        return win32_cap(filename='temp_image')
    pos = crop_position[name]
    return win32_cap(filename='temp_image', rect=pos)