From d618f21cc2b8590606de86e07b5527af8758ae7d Mon Sep 17 00:00:00 2001 From: Quentin Geissmann Date: Tue, 14 Jul 2020 15:09:39 -0700 Subject: [PATCH] patch division by zero (#122) --- src/ethoscope/trackers/adaptive_bg_tracker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ethoscope/trackers/adaptive_bg_tracker.py b/src/ethoscope/trackers/adaptive_bg_tracker.py index 308dd880..e57ff787 100644 --- a/src/ethoscope/trackers/adaptive_bg_tracker.py +++ b/src/ethoscope/trackers/adaptive_bg_tracker.py @@ -288,7 +288,10 @@ def _pre_process_input_minimal(self, img, mask, t, darker_fg=True): # mean = cv2.mean(self._buff_grey, mask) - scale = 128. / mean[0] + try: + scale = 128. / mean[0] + except ZeroDivisionError: + raise NoPositionError cv2.multiply(self._buff_grey, scale, dst = self._buff_grey) @@ -508,4 +511,4 @@ def _track(self, img, grey, mask,t): self._previous_shape=np.copy(hull) - return [out] \ No newline at end of file + return [out]