mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-25 10:01:10 +00:00
Fix: Amount slider on light background
This commit is contained in:
parent
2441e66f91
commit
02c8e475a6
@ -49,7 +49,7 @@ class Slider:
|
|||||||
total = area[2] - area[0]
|
total = area[2] - area[0]
|
||||||
|
|
||||||
parameters = {
|
parameters = {
|
||||||
'prominence': 15,
|
'prominence': 10,
|
||||||
'wlen': wlen,
|
'wlen': wlen,
|
||||||
'width': 2,
|
'width': 2,
|
||||||
'distance': wlen / 2,
|
'distance': wlen / 2,
|
||||||
@ -58,6 +58,7 @@ class Slider:
|
|||||||
peaks, _ = signal.find_peaks(image, **parameters)
|
peaks, _ = signal.find_peaks(image, **parameters)
|
||||||
peaks //= wlen
|
peaks //= wlen
|
||||||
diff = np.diff(peaks)
|
diff = np.diff(peaks)
|
||||||
|
# print(diff)
|
||||||
|
|
||||||
# Mask controller
|
# Mask controller
|
||||||
# Controller has orange border (240, 150, 57) and white center
|
# Controller has orange border (240, 150, 57) and white center
|
||||||
|
@ -37,7 +37,7 @@ def image_color_count(image, color, threshold=221):
|
|||||||
class WhiteStrip(Ocr):
|
class WhiteStrip(Ocr):
|
||||||
def pre_process(self, image):
|
def pre_process(self, image):
|
||||||
mask = color_similarity_2d(image, color=(255, 255, 255))
|
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)
|
mask = np.mean(mask, axis=0)
|
||||||
point = np.array(cv2.findNonZero(mask))[:, 0, 1]
|
point = np.array(cv2.findNonZero(mask))[:, 0, 1]
|
||||||
@ -52,6 +52,13 @@ class SynthesizeItemName(OcrItemName, WhiteStrip):
|
|||||||
pass
|
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):
|
class SynthesizeInventoryManager(InventoryManager):
|
||||||
@cached_property
|
@cached_property
|
||||||
def dic_item_index(self):
|
def dic_item_index(self):
|
||||||
@ -359,7 +366,7 @@ class Synthesize(CombatObtain, ItemUI):
|
|||||||
logger.hr('Synthesize amount set', level=2)
|
logger.hr('Synthesize amount set', level=2)
|
||||||
slider = Slider(main=self, slider=SYNTHESIZE_SLIDER)
|
slider = Slider(main=self, slider=SYNTHESIZE_SLIDER)
|
||||||
slider.set(value, total)
|
slider.set(value, total)
|
||||||
ocr = Digit(SYNTHESIZE_AMOUNT, lang=server.lang)
|
ocr = SynthesizeItemAmount(SYNTHESIZE_AMOUNT, lang=server.lang)
|
||||||
self.ui_ensure_index(
|
self.ui_ensure_index(
|
||||||
value, letter=ocr, next_button=SYNTHESIZE_PLUS, prev_button=SYNTHESIZE_MINUS, interval=(0.1, 0.2))
|
value, letter=ocr, next_button=SYNTHESIZE_PLUS, prev_button=SYNTHESIZE_MINUS, interval=(0.1, 0.2))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user