Fix: Amount slider on light background

This commit is contained in:
LmeSzinc 2024-06-18 19:10:33 +08:00
parent 2441e66f91
commit 02c8e475a6
2 changed files with 11 additions and 3 deletions

View File

@ -49,7 +49,7 @@ class Slider:
total = area[2] - area[0]
parameters = {
'prominence': 15,
'prominence': 10,
'wlen': wlen,
'width': 2,
'distance': wlen / 2,
@ -58,6 +58,7 @@ class Slider:
peaks, _ = signal.find_peaks(image, **parameters)
peaks //= wlen
diff = np.diff(peaks)
# print(diff)
# Mask controller
# Controller has orange border (240, 150, 57) and white center

View File

@ -37,7 +37,7 @@ def image_color_count(image, color, threshold=221):
class WhiteStrip(Ocr):
def pre_process(self, image):
mask = color_similarity_2d(image, color=(255, 255, 255))
mask = cv2.inRange(mask, 180, 255, dst=mask)
mask = cv2.inRange(mask, 160, 255, dst=mask)
mask = np.mean(mask, axis=0)
point = np.array(cv2.findNonZero(mask))[:, 0, 1]
@ -52,6 +52,13 @@ class SynthesizeItemName(OcrItemName, WhiteStrip):
pass
class SynthesizeItemAmount(Digit, WhiteStrip):
def pre_process(self, image):
image = super().pre_process(image)
image = cv2.subtract((255, 255, 255, 0), image)
return image
class SynthesizeInventoryManager(InventoryManager):
@cached_property
def dic_item_index(self):
@ -359,7 +366,7 @@ class Synthesize(CombatObtain, ItemUI):
logger.hr('Synthesize amount set', level=2)
slider = Slider(main=self, slider=SYNTHESIZE_SLIDER)
slider.set(value, total)
ocr = Digit(SYNTHESIZE_AMOUNT, lang=server.lang)
ocr = SynthesizeItemAmount(SYNTHESIZE_AMOUNT, lang=server.lang)
self.ui_ensure_index(
value, letter=ocr, next_button=SYNTHESIZE_PLUS, prev_button=SYNTHESIZE_MINUS, interval=(0.1, 0.2))