diff --git a/module/base/base.py b/module/base/base.py index 2ece6a4ce..e2443e00f 100644 --- a/module/base/base.py +++ b/module/base/base.py @@ -273,7 +273,7 @@ class ModuleBase: Returns: Button: Or None if nothing matched. """ - image = color_similarity_2d(self.image_crop(area), color=color) + image = color_similarity_2d(self.image_crop(area, copy=False), color=color) points = np.array(np.where(image > color_threshold)).T[:, ::-1] if points.shape[0] < encourage ** 2: # Not having enough pixels to match diff --git a/tasks/character/switch.py b/tasks/character/switch.py index a30e25796..bf5e750af 100644 --- a/tasks/character/switch.py +++ b/tasks/character/switch.py @@ -122,7 +122,7 @@ class CharacterSwitch(UI): expected_peaks = np.array([201, 279, 357, 435]) expected_peaks_in_area = expected_peaks - area[1] # Use Luminance to fit H264 video stream - image = rgb2luma(crop(self.device.image, area)) + image = rgb2luma(crop(self.device.image, area, copy=False)) # Remove character names kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3)) image = cv2.erode(image, kernel) diff --git a/tasks/combat/skill.py b/tasks/combat/skill.py index 081c9b44d..fb3bdcda2 100644 --- a/tasks/combat/skill.py +++ b/tasks/combat/skill.py @@ -47,7 +47,7 @@ class CombatSkill(UI): break # New skill icon if prev_image is not None: - if not match_template(self.image_crop(button), prev_image): + if not match_template(self.image_crop(button, copy=False), prev_image): logger.info(f'Skill used: {button} (icon changed)') break diff --git a/tasks/combat/state.py b/tasks/combat/state.py index cac86c67c..e9e32a7f5 100644 --- a/tasks/combat/state.py +++ b/tasks/combat/state.py @@ -22,7 +22,7 @@ class CombatState(UI): return False def _is_combat_button_active(self, button): - image = rgb2luma(self.image_crop(button)) + image = rgb2luma(self.image_crop(button, copy=False)) lines = cv2.reduce(image, 1, cv2.REDUCE_AVG).flatten() # [122 122 122 182 141 127 139 135 130 135 136 141 147 149 149 150 147 145 # 148 150 150 150 150 150 144 138 134 141 136 133 173 183 130 128 127 126] diff --git a/tasks/combat/support.py b/tasks/combat/support.py index de060cca1..0eabf9542 100644 --- a/tasks/combat/support.py +++ b/tasks/combat/support.py @@ -30,7 +30,7 @@ class SupportCharacter: def __init__(self, name, screenshot, similarity=0.75): self.name = name self.image = self._scale_character() - self.screenshot = crop(screenshot, SupportCharacter._crop_area) + self.screenshot = crop(screenshot, SupportCharacter._crop_area, copy=False) self.similarity = similarity self.button = self._find_character() diff --git a/tasks/daily/daily_quest.py b/tasks/daily/daily_quest.py index c186101c9..744f8ccc4 100644 --- a/tasks/daily/daily_quest.py +++ b/tasks/daily/daily_quest.py @@ -33,10 +33,10 @@ class DailyQuestOcr(Ocr): def pre_process(self, image): image = super().pre_process(image) - image = crop(image, OCR_DAILY_QUEST.area) + image = crop(image, OCR_DAILY_QUEST.area, copy=False) mask = MASK_DAILY_QUEST.matched_button.image # Remove "+200Activity" - cv2.bitwise_and(image, mask, dst=image) + image = cv2.bitwise_and(image, mask) return image def after_process(self, result): diff --git a/tasks/dungeon/state.py b/tasks/dungeon/state.py index 4db588c59..c7af7138c 100644 --- a/tasks/dungeon/state.py +++ b/tasks/dungeon/state.py @@ -39,7 +39,7 @@ class DungeonState(UI): ) ocr = OcrSimUniPoint(OCR_SIMUNI_POINT) - value, _, total = ocr.ocr_single_line(crop(image, area), direct_ocr=True) + value, _, total = ocr.ocr_single_line(crop(image, area, copy=False), direct_ocr=True) if total and value <= total: logger.attr('SimulatedUniverse', f'{value}/{total}') self.config.stored.SimulatedUniverse.set(value, total) diff --git a/tasks/dungeon/ui.py b/tasks/dungeon/ui.py index 01d0659cb..4ab40761e 100644 --- a/tasks/dungeon/ui.py +++ b/tasks/dungeon/ui.py @@ -334,7 +334,7 @@ class DungeonUI(DungeonState): # Check if having any content # List background: 254, guild border: 225 - r, g, b = cv2.split(self.image_crop(LIST_LOADED_CHECK)) + r, g, b = cv2.split(self.image_crop(LIST_LOADED_CHECK, copy=False)) minimum = cv2.min(cv2.min(r, g), b) minimum = inrange(minimum, lower=0, upper=180) if minimum.size > 100: diff --git a/tasks/forgotten_hall/team.py b/tasks/forgotten_hall/team.py index ac91a6ca1..5317c360a 100644 --- a/tasks/forgotten_hall/team.py +++ b/tasks/forgotten_hall/team.py @@ -35,7 +35,7 @@ class ForgottenHallTeam(UI): continue def is_character_chosen(self, button: ButtonWrapper) -> bool: - image = color_similarity_2d(self.image_crop(button), color=(255, 255, 255)) + image = color_similarity_2d(self.image_crop(button, copy=False), color=(255, 255, 255)) color = cv2.mean(image)[0] # print(button, color) # Chosen: diff --git a/tasks/forgotten_hall/ui.py b/tasks/forgotten_hall/ui.py index 14e9c3d59..08b1aa7a8 100644 --- a/tasks/forgotten_hall/ui.py +++ b/tasks/forgotten_hall/ui.py @@ -23,7 +23,7 @@ class ForgottenHallStageOcr(Ocr): def _find_number(self, image): raw = image.copy() area = OCR_STAGE.area - image = crop(raw, area) + image = crop(raw, area, copy=False) yellow = color_similarity_2d(image, color=(255, 200, 112)) gray = color_similarity_2d(image, color=(100, 109, 134)) image = np.maximum(yellow, gray) diff --git a/tasks/item/synthesize.py b/tasks/item/synthesize.py index 7867c0e04..fc15f9256 100644 --- a/tasks/item/synthesize.py +++ b/tasks/item/synthesize.py @@ -56,11 +56,11 @@ class Synthesize(CombatObtain): Pages: in: page_synthesize """ - image = self.image_crop(button) + image = self.image_crop(button, copy=False) image = cv2.GaussianBlur(image, (3, 3), 0) x2, y2 = image_size(image) y1 = y2 - int(y2 // 4) - image = crop(image, (0, y1, x2, y2)) + image = crop(image, (0, y1, x2, y2), copy=False) # self.device.image_show(image) # print(image.shape) diff --git a/tasks/map/minimap/minimap.py b/tasks/map/minimap/minimap.py index ce6a78c16..1b7c5bcce 100644 --- a/tasks/map/minimap/minimap.py +++ b/tasks/map/minimap/minimap.py @@ -150,7 +150,7 @@ class Minimap(MapResource): # Image.fromarray((local_maximum * 255).astype(np.uint8)).save('local_maximum.png') # Calculate the precise location using CUBIC - # precise = crop(result, area=area_offset((-4, -4, 4, 4), offset=local_loca)) + # precise = crop(result, area=area_offset((-4, -4, 4, 4), offset=local_loca), copy=False) # precise_sim, precise_loca = cubic_find_maximum(precise, precision=0.05) # precise_loca -= 5 precise_loca = np.array((0, 0)) @@ -190,7 +190,7 @@ class Minimap(MapResource): loca = state.loca local_loca = state.local_loca - precise = crop(result, area=area_offset((-4, -4, 4, 4), offset=loca)) + precise = crop(result, area=area_offset((-4, -4, 4, 4), offset=loca), copy=False) precise_sim, precise_loca = cubic_find_maximum(precise, precision=0.05) precise_loca -= 5 @@ -265,7 +265,7 @@ class Minimap(MapResource): logger.warning('No direction arrow on minimap') return - image = crop(image, area=area) + image = crop(image, area=area, copy=False) scale = self.DIRECTION_ROTATION_SCALE * self.DIRECTION_SEARCH_SCALE mapping = cv2.resize(image, None, fx=scale, fy=scale, interpolation=cv2.INTER_NEAREST) result = cv2.matchTemplate(self.ArrowRotateMap, mapping, cv2.TM_CCOEFF_NORMED) diff --git a/tasks/map/resource/generate.py b/tasks/map/resource/generate.py index cefa5f4d8..7b1032433 100644 --- a/tasks/map/resource/generate.py +++ b/tasks/map/resource/generate.py @@ -55,7 +55,7 @@ class ResourceGenerator(ResourceConst): arrows = {} for degree in range(0, 360): rotated = rotate_bound(image, degree) - rotated = crop(rotated, area=get_bbox(rotated, threshold=15)) + rotated = crop(rotated, area=get_bbox(rotated, threshold=15), copy=False) # rotated = cv2.resize(rotated, None, fx=self.ROTATE, fy=self.ROTATE, interpolation=cv2.INTER_NEAREST) rotated = color_similarity_2d(rotated, color=self.DIRECTION_ARROW_COLOR) arrows[degree] = rotated diff --git a/tasks/map/resource/resource.py b/tasks/map/resource/resource.py index 2411e00e3..b5cef51d5 100644 --- a/tasks/map/resource/resource.py +++ b/tasks/map/resource/resource.py @@ -101,7 +101,7 @@ class MapResource(ResourceConst): Crop the minimap area on image. """ area = area_offset((-radius, -radius, radius, radius), offset=self.MINIMAP_CENTER) - image = crop(image, area) + image = crop(image, area, copy=False) return image def get_circle_mask(self, image):