Esempio n. 1
0
def create_output_opencv(input_map, coords, output_file, full_map=False):
    if full_map:
        output_slice = slice(None)
    else:
        output_slice = create_slice(
            *find_path_bounds(input_map.shape[0], coords))
    cv2.imwrite(output_file, input_map[output_slice])
Esempio n. 2
0
    def _get_scaled_context(self):
        # Context defines the area that the template matching will be limited to.
        # This area gets larger each time a match is missed to account for movement processing.
        context_slice = slice(None)

        if self.last_known_position:
            max_reachable_dist = self._calculate_max_travel_distance()

            context_coords, context_size = find_path_bounds(
                self.gray_map.shape[0],
                [scale_coords(self.last_known_position, self.scale)],
                crop_border=0,
                min_size=max_reachable_dist)
            context_slice = create_slice(context_coords, context_size)

        return context_slice
Esempio n. 3
0
    def run(self):
        self.percent_max_update.emit(0)
        self.percent_update.emit(0)

        match = PUBGISMatch(self.minimap_iterator)

        self.minimap_update.emit(self.preview_map)

        for percent, timestamp, full_position in match.process_match():
            if percent is not None:
                self.percent_max_update.emit(100)
                self.percent_update.emit(percent)

            plot_coordinate_line(self.preview_map, self.full_positions,
                                 full_position, self.parent.path_color(),
                                 self.parent.thickness_spinbox.value())

            self.full_positions.append(full_position)
            self.timestamps.append(timestamp)

            if self.output_flags & OutputFlags.LIVE_PREVIEW:
                preview_coords, preview_size = find_path_bounds(
                    PUBGISMatch.full_map.shape[0], self.full_positions)

                preview_slice = create_slice(preview_coords, preview_size)

                alpha = self.parent.path_color.alpha
                blended = cv2.addWeighted(self.base_map_alpha[preview_slice],
                                          1 - alpha,
                                          self.preview_map[preview_slice],
                                          alpha, 0)

                self.minimap_update.emit(blended)

            if self.isInterruptionRequested():
                self.minimap_iterator.stop()

        if self.isInterruptionRequested():
            self.percent_max_update.emit(100)

        self.percent_update.emit(100)

        alpha = self.parent.path_color.alpha

        if self.output_flags & OutputFlags.FULL_MAP:
            blended = cv2.addWeighted(self.base_map_alpha, 1 - alpha,
                                      self.preview_map, alpha, 0)
            create_output_opencv(blended,
                                 self.full_positions,
                                 self.output_file,
                                 full_map=True)
        elif self.output_flags & OutputFlags.CROPPED_MAP:
            blended = cv2.addWeighted(self.base_map_alpha, 1 - alpha,
                                      self.preview_map, alpha, 0)
            create_output_opencv(blended, self.full_positions,
                                 self.output_file)

        if self.output_flags & OutputFlags.JSON:
            pre, _ = os.path.splitext(self.output_file)
            json_file = pre + ".json"
            data = create_json_data(self.full_positions, self.timestamps)
            output_json(json_file, data)
Esempio n. 4
0
def test_find_path_bounds(map_size, input_coords, expected_bounds):
    assert find_path_bounds(map_size, input_coords) == expected_bounds