Skip to content

Commit e56442d

Browse files
authored
Merge pull request springbok#135 from wonder99/main
Correct pausing/unpausing of OCR.
2 parents 339ce0a + bedc6f4 commit e56442d

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/ball_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def eq(self, other):
389389
if (roi != BallMetrics.BACK_SPIN and
390390
((roi != BallMetrics.SIDE_SPIN and self.launch_monitor != LaunchMonitor.TRUGOLF_APOGEE) or
391391
self.launch_monitor == LaunchMonitor.TRUGOLF_APOGEE) and result != previous_result):
392-
logging.debug(f'previous_metric: {previous_result} result: {result}')
392+
logging.debug('ROI {: <15} was:{: >6} is:{: >6}'.format(roi, previous_result, result))
393393
diff_count = diff_count + 1
394394
# Check if all values are 0, some users use practice instead of range and there is a screen flicker
395395
# that causes an invalid shot with all invalid values so all values are still 0. Check if all values

src/screenshot.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,15 @@ def capture_screenshot(self, device: Device, rois_setup=False):
6969
# Check if new shot
7070
self.new_shot = False
7171
self.screenshot_new = False
72-
mse = 100
72+
if self.settings.device_id == LaunchMonitor.UNEEKOR:
73+
mse_min = 400
74+
else:
75+
mse_min = 100
76+
mse = mse_min
77+
7378
if not self.previous_screenshot_image is None:
7479
mse = self.mse(self.previous_screenshot_image, self.screenshot_image)
75-
if mse >= 100:
80+
if mse >= mse_min or self.first:
7681
self.screenshot_new = True
7782
self.previous_screenshot_image = self.screenshot_image
7883
self.image()

src/screenshot_base.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,17 @@ def ocr_image(self):
243243
self.balldata.process_putt_data(ocr_result, roi, self.previous_balldata)
244244
else:
245245
self.balldata.process_shot_data(ocr_result, roi, self.previous_balldata, self.selected_club, self.settings.mevo_plus['offline_mode'])
246+
246247
# Correct metrics if invalid smash factor
247248
if self.balldata.putt_type is None:
248249
self.balldata.check_smash_factor(self.selected_club)
250+
251+
# Ignore first shot at startup
252+
if self.first:
253+
logging.debug('First shot, ignoring')
254+
self.first = False
255+
self.previous_balldata = self.balldata.__copy__()
256+
249257
if not self.previous_balldata is None:
250258
diff_count = self.balldata.eq(self.previous_balldata)
251259
else:
@@ -279,12 +287,6 @@ def ocr_image(self):
279287
self.previous_balldata = self.balldata.__copy__()
280288
else:
281289
logging.debug('Not a new shot')
282-
# Ignore first shot at startup
283-
if self.first:
284-
logging.debug('First shot, ignoring')
285-
self.first = False
286-
self.balldata.new_shot = False
287-
self.new_shot = False
288290
finally:
289291
tesserocr_api.End()
290292

0 commit comments

Comments
 (0)