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:
@ -11,7 +11,7 @@ detector = cv2.QRCodeDetector()
|
|||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
def get_values(window: WindowClient):
|
def get_values(window: WindowClient):
|
||||||
values = None
|
values = None
|
||||||
for _ in range(5):
|
for _ in range(6):
|
||||||
img = window.processed_image()
|
img = window.processed_image()
|
||||||
if img is None:
|
if img is None:
|
||||||
logging.debug("Couldn't capture window.")
|
logging.debug("Couldn't capture window.")
|
||||||
@ -21,8 +21,7 @@ def get_values(window: WindowClient):
|
|||||||
window.crop = _get_qr_location(img)
|
window.crop = _get_qr_location(img)
|
||||||
if not window.crop:
|
if not window.crop:
|
||||||
logging.debug("FishyQR not found.")
|
logging.debug("FishyQR not found.")
|
||||||
continue
|
continue
|
||||||
img = window.processed_image()
|
|
||||||
|
|
||||||
values = _get_values_from_image(img)
|
values = _get_values_from_image(img)
|
||||||
if not values:
|
if not values:
|
||||||
|
@ -65,6 +65,10 @@ class WindowClient:
|
|||||||
if self.scale is not None:
|
if self.scale is not None:
|
||||||
temp_img = cv2.resize(temp_img, (self.scale[0], self.scale[1]), interpolation=cv2.INTER_AREA)
|
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
|
return temp_img
|
||||||
|
|
||||||
def processed_image(self, func=None):
|
def processed_image(self, func=None):
|
||||||
|
@ -25,7 +25,7 @@ class WindowServer:
|
|||||||
"""
|
"""
|
||||||
Records the game window, and allows to create instance to process it
|
Records the game window, and allows to create instance to process it
|
||||||
"""
|
"""
|
||||||
Screen = None
|
Screen: np.ndarray = None
|
||||||
windowOffset = None
|
windowOffset = None
|
||||||
hwnd = None
|
hwnd = None
|
||||||
status = Status.STOPPED
|
status = Status.STOPPED
|
||||||
|
Reference in New Issue
Block a user