mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-25 03:32:38 +08:00
Fix: Adaptive OCR_OIL to handle black overlay
This commit is contained in:
@@ -4,12 +4,12 @@ import cv2
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.campaign.assets import OCR_EVENT_PT, OCR_COIN, OCR_OIL, OCR_OIL_CHECK
|
from module.base.utils import color_similar, get_color
|
||||||
|
from module.campaign.assets import OCR_COIN, OCR_EVENT_PT, OCR_OIL, OCR_OIL_CHECK
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.ocr import Ocr, Digit
|
from module.ocr.ocr import Digit, Ocr
|
||||||
from module.ui.ui import UI
|
from module.ui.ui import UI
|
||||||
|
|
||||||
OCR_OIL = Digit(OCR_OIL, name='OCR_OIL', letter=(247, 247, 247), threshold=128)
|
|
||||||
OCR_COIN = Digit(OCR_COIN, name='OCR_COIN', letter=(239, 239, 239), threshold=128)
|
OCR_COIN = Digit(OCR_COIN, name='OCR_COIN', letter=(239, 239, 239), threshold=128)
|
||||||
|
|
||||||
|
|
||||||
@@ -78,7 +78,21 @@ class CampaignStatus(UI):
|
|||||||
return amount
|
return amount
|
||||||
|
|
||||||
def _get_oil(self):
|
def _get_oil(self):
|
||||||
return OCR_OIL.ocr(self.device.image)
|
# Update offset
|
||||||
|
_ = self.appear(OCR_OIL_CHECK)
|
||||||
|
|
||||||
|
color = get_color(self.device.image, OCR_OIL_CHECK.button)
|
||||||
|
if color_similar(color, OCR_OIL_CHECK.color):
|
||||||
|
# Original color
|
||||||
|
ocr = Digit(OCR_OIL, name='OCR_OIL', letter=(247, 247, 247), threshold=128)
|
||||||
|
elif color_similar(color, (59, 59, 64)):
|
||||||
|
# With black overlay
|
||||||
|
ocr = Digit(OCR_OIL, name='OCR_OIL', letter=(165, 165, 165), threshold=128)
|
||||||
|
else:
|
||||||
|
logger.warning(f'Unexpected OCR_OIL_CHECK color')
|
||||||
|
ocr = Digit(OCR_OIL, name='OCR_OIL', letter=(247, 247, 247), threshold=128)
|
||||||
|
|
||||||
|
return ocr.ocr(self.device.image)
|
||||||
|
|
||||||
def get_oil(self, skip_first_screenshot=True):
|
def get_oil(self, skip_first_screenshot=True):
|
||||||
"""
|
"""
|
||||||
@@ -101,7 +115,7 @@ class CampaignStatus(UI):
|
|||||||
logger.info('No oil icon')
|
logger.info('No oil icon')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
amount = OCR_OIL.ocr(self.device.image)
|
amount = self._get_oil()
|
||||||
if amount >= 100:
|
if amount >= 100:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user