mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
#128 added few checks before image leaves WindowClient which was causing exception
This commit is contained in:
parent
fb54ca4826
commit
3567f062b0
fishy/engine/common
@ -11,7 +11,7 @@ detector = cv2.QRCodeDetector()
|
||||
# noinspection PyBroadException
|
||||
def get_values(window: WindowClient):
|
||||
values = None
|
||||
for _ in range(5):
|
||||
for _ in range(6):
|
||||
img = window.processed_image()
|
||||
if img is None:
|
||||
logging.debug("Couldn't capture window.")
|
||||
@ -21,8 +21,7 @@ def get_values(window: WindowClient):
|
||||
window.crop = _get_qr_location(img)
|
||||
if not window.crop:
|
||||
logging.debug("FishyQR not found.")
|
||||
continue
|
||||
img = window.processed_image()
|
||||
continue
|
||||
|
||||
values = _get_values_from_image(img)
|
||||
if not values:
|
||||
|
@ -65,6 +65,10 @@ class WindowClient:
|
||||
if self.scale is not None:
|
||||
temp_img = cv2.resize(temp_img, (self.scale[0], self.scale[1]), interpolation=cv2.INTER_AREA)
|
||||
|
||||
# need ot check again after crop/resize
|
||||
if temp_img.size == 0:
|
||||
return None
|
||||
|
||||
return temp_img
|
||||
|
||||
def processed_image(self, func=None):
|
||||
|
@ -25,7 +25,7 @@ class WindowServer:
|
||||
"""
|
||||
Records the game window, and allows to create instance to process it
|
||||
"""
|
||||
Screen = None
|
||||
Screen: np.ndarray = None
|
||||
windowOffset = None
|
||||
hwnd = None
|
||||
status = Status.STOPPED
|
||||
|
Loading…
Reference in New Issue
Block a user