@@ -252,7 +252,7 @@ def __update_live_image_details(self, capture: MatLike | None, called_from_timer
252
252
if called_from_timer :
253
253
if self .is_running or self .start_image :
254
254
return
255
- capture , _ = self .capture_method .get_frame ()
255
+ capture = self .capture_method .get_frame ()
256
256
257
257
# Update title from target window or Capture Device name
258
258
capture_region_window_label = (
@@ -310,7 +310,7 @@ def __start_image_function(self):
310
310
self .start_image_status_value_label .setText ("ready" )
311
311
self .__update_split_image (self .start_image )
312
312
313
- capture , _ = self .__get_capture_for_comparison ()
313
+ capture = self .__get_capture_for_comparison ()
314
314
start_image_threshold = self .start_image .get_similarity_threshold (self )
315
315
start_image_similarity = self .start_image .compare_with_capture (self , capture )
316
316
@@ -390,7 +390,7 @@ def __take_screenshot(self):
390
390
screenshot_index += 1
391
391
392
392
# Grab screenshot of capture region
393
- capture , _ = self .capture_method .get_frame ()
393
+ capture = self .capture_method .get_frame ()
394
394
if not is_valid_image (capture ):
395
395
error_messages .region ()
396
396
return
@@ -415,14 +415,16 @@ def __check_fps(self):
415
415
416
416
# run X iterations of screenshotting capture region + comparison + displaying.
417
417
t0 = time ()
418
+ last_capture : MatLike | None = None
418
419
for image in images :
419
420
count = 0
420
421
while count < CHECK_FPS_ITERATIONS :
421
- capture , is_old_image = self .__get_capture_for_comparison ()
422
- _ = image .compare_with_capture (self , capture )
423
- # TODO: If is_old_image=true is always returned, this becomes an infinite loop
424
- if not is_old_image :
422
+ new_capture = self .__get_capture_for_comparison ()
423
+ _ = image .compare_with_capture (self , new_capture )
424
+ # TODO: If an old image is always returned, this becomes an infinite loop
425
+ if new_capture is not last_capture :
425
426
count += 1
427
+ last_capture = new_capture
426
428
427
429
# calculate FPS
428
430
t1 = time ()
@@ -641,7 +643,7 @@ def __similarity_threshold_loop(self, number_of_split_images: int, dummy_splits_
641
643
642
644
start = time ()
643
645
while True :
644
- capture , _ = self .__get_capture_for_comparison ()
646
+ capture = self .__get_capture_for_comparison ()
645
647
646
648
if self .__reset_if_should (capture ):
647
649
return True
@@ -710,7 +712,7 @@ def __pause_loop(self, stop_time: float, message: str):
710
712
pause_split_image_number = self .split_image_number
711
713
while True :
712
714
# Calculate similarity for Reset Image
713
- if self .__reset_if_should (self .__get_capture_for_comparison ()[ 0 ] ):
715
+ if self .__reset_if_should (self .__get_capture_for_comparison ()):
714
716
return True
715
717
716
718
time_delta = time () - start_time
@@ -785,7 +787,7 @@ def gui_changes_on_reset(self, safe_to_reload_start_image: bool = False):
785
787
786
788
def __get_capture_for_comparison (self ):
787
789
"""Grab capture region and resize for comparison."""
788
- capture , is_old_image = self .capture_method .get_frame ()
790
+ capture = self .capture_method .get_frame ()
789
791
790
792
# This most likely means we lost capture
791
793
# (ie the captured window was closed, crashed, lost capture device, etc.)
@@ -800,10 +802,10 @@ def __get_capture_for_comparison(self):
800
802
self .live_image .setText (message )
801
803
recovered = self .capture_method .recover_window (self .settings_dict ["captured_window_title" ])
802
804
if recovered :
803
- capture , _ = self .capture_method .get_frame ()
805
+ capture = self .capture_method .get_frame ()
804
806
805
807
self .__update_live_image_details (capture )
806
- return capture , is_old_image
808
+ return capture
807
809
808
810
def __reset_if_should (self , capture : MatLike | None ):
809
811
"""Checks if we should reset, resets if it's the case, and returns the result."""
0 commit comments