예제 #1
0
    def execute(self):
        reset_region = as64core.get_region(as64core.RESET_REGION)
        # TODO: SWITCH TO USING FADE_STATUS
        # If centre of screen is black, and the current split conditions are met, trigger split
        if is_black(reset_region, self._black_threshold) and as64core.incoming_split(star_count=False) and as64core.current_split().split_type == as64core.SPLIT_FADE_ONLY:
            as64core.split()
            self._split_occurred = True

        # Check for a match against the reset_template (SM64 logo)
        if as64core.fade_status == self._is_reset(reset_region, self._reset_template):
            as64core.enable_predictions(True)
            self._split_occurred = False
            self._reset()
            return self.signals["RESET"]
        elif self._is_reset(reset_region, self._reset_template_2):
            as64core.enable_predictions(True)
            self._split_occurred = False
            self._reset()
            return self.signals["RESET"]

        # If both star count, and life count are still black, reprocess fadeout, otherwise fadeout completed
        if as64core.fade_status in (as64core.FADEOUT_COMPLETE, as64core.FADEOUT_PARTIAL):
            return self.signals["LOOP"]
        else:
            as64core.enable_predictions(True)
            self._split_occurred = False
            return self.signals["COMPLETE"]
예제 #2
0
    def run(self):
        self._running = True
        reset_occurred = False
        frame = 0

        generated_frames = []

        while self._running:
            c_time = time.time()
            try:
                self._game_capture.capture()
            except:
                self.error.emit("Unable to capture " +
                                config.get("game", "process_name"))
                self.stop()
                break

            reset_region = self._game_capture.get_region(RESET_REGION)
            fadeout_region = self._game_capture.get_region(FADEOUT_REGION)

            if is_black(fadeout_region, 0.1, 0.97):
                reset_occurred = True

            if reset_occurred:
                if not is_black(fadeout_region,
                                config.get("thresholds", "black_threshold"),
                                0.99):
                    frame += 1

                    if frame <= self.CAPTURE_COUNT:
                        generated_frames.append(reset_region)
                    else:
                        self._running = False

            try:
                time.sleep((1 / 29.97) - (time.time() - c_time))
            except ValueError:
                pass

        for i, frame in enumerate(generated_frames):
            cv2.imwrite(
                ResetGeneratorDialog.TEMPLATE_DIR + "generated_temp_" +
                str(i + 1) + ".jpg", frame)

        self.generated.emit()
예제 #3
0
파일: final.py 프로젝트: Kainev/AutoSplit64
    def _star_visible(self, threshold=0.999):
        no_hud = as64core.get_region(as64core.NO_HUD_REGION)

        lower = np.array(self.star_lower_bound, dtype="uint8")
        upper = np.array(self.star_upper_bound, dtype="uint8")

        star_mask = cv2.inRange(no_hud, lower, upper)
        output = cv2.bitwise_and(no_hud, no_hud, mask=star_mask)

        return not is_black(output, 0.1, threshold)
예제 #4
0
    def _power_check(self):
        power_region = as64core.get_region(as64core.POWER_REGION)

        lower = np.array(self.power_lower_bound, dtype="uint8")
        upper = np.array(self.power_upper_bound, dtype="uint8")

        power_mask = cv2.inRange(power_region, lower, upper)
        output = cv2.bitwise_and(power_region, power_region, mask=power_mask)

        return not is_black(output, 0.1, 0.9)
예제 #5
0
    def execute(self):
        no_hud = as64core.get_region(as64core.GAME_REGION)

        if as64core.fade_status == as64core.FADEOUT_COMPLETE:
            c_time = time.time()
            print("Green", c_time - self.green_found_time)
            print("Red", c_time - self.red_found_time)
            print("Grey", c_time - self.grey_found_time)

            if c_time - self.red_found_time < 0.4 and c_time - self.green_found_time < 0.4 and c_time - self.grey_found_time > 0.75:
                as64core.split()
            return ProcessLBLJ.FADEOUT

        red_mask = cv2.inRange(no_hud, self.red_lower_bound,
                               self.red_upper_bound)
        red_output = cv2.bitwise_and(no_hud, no_hud, mask=red_mask)

        if not is_black(red_output, 0.1, 0.99):
            print("RED")
            self.red_found_time = time.time()

        grey_mask = cv2.inRange(no_hud, self.grey_lower_bound,
                                self.grey_upper_bound)
        grey_output = cv2.bitwise_and(no_hud, no_hud, mask=grey_mask)

        if not is_black(grey_output, 0.16, 0.88):
            cv2.imwrite("grey.png", grey_output)
            print("GREY!")
            self.grey_found_time = time.time()

        if cv2.inRange(no_hud, self.green_lower_bound,
                       self.green_upper_bound).any():
            print("GREEN FOUND!")
            self.green_found_time = time.time()

        return Process.LOOP
예제 #6
0
파일: ddd.py 프로젝트: Kainev/AutoSplit64
    def execute(self):
        no_hud = as64core.get_region(as64core.GAME_REGION)

        if as64core.fade_status in (as64core.FADEOUT_PARTIAL,
                                    as64core.FADEOUT_COMPLETE):
            return self.signals["FADEOUT"]

        lower = np.array(self.portal_lower_bound, dtype="uint8")
        upper = np.array(self.portal_upper_bound, dtype="uint8")

        portal_mask = cv2.inRange(no_hud, lower, upper)
        output = cv2.bitwise_and(no_hud, no_hud, mask=portal_mask)

        if not is_black(output, 0.1, 0.99):
            return self.signals["FOUND"]
        else:
            return self.signals["LOOP"]
예제 #7
0
파일: xcam.py 프로젝트: Kainev/AutoSplit64
    def execute(self):
        if as64core.fade_status in (as64core.FADEOUT_PARTIAL, as64core.FADEOUT_COMPLETE):
            return self.signals["FADEOUT"]

        if as64core.fadeout_count == 1:
            as64core.fps = 29.97
            as64core.enable_predictions(not self._predictions)
            xcam = as64core.get_region(as64core.XCAM_REGION)
            lower = np.array(self.lower_bound, dtype="uint8")
            upper = np.array(self.upper_bound, dtype="uint8")

            mask = cv2.inRange(xcam, lower, upper)
            output = cv2.bitwise_and(xcam, xcam, mask=mask)

            if not is_black(output, 0.1, 0.7):
                as64core.split()
                as64core.fps = 10
                as64core.fadeout_count = 0
                as64core.set_in_game(True)
                return self.signals["START"]

        return self.signals["LOOP"]