mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-26 19:06:11 +01:00
avoid rare divide by zero
This commit is contained in:
parent
ac30091258
commit
b82d75b79e
@ -567,6 +567,9 @@ class EventsPerSecond:
|
|||||||
# compute the (approximate) events in the last n seconds
|
# compute the (approximate) events in the last n seconds
|
||||||
now = datetime.datetime.now().timestamp()
|
now = datetime.datetime.now().timestamp()
|
||||||
seconds = min(now - self._start, last_n_seconds)
|
seconds = min(now - self._start, last_n_seconds)
|
||||||
|
# avoid divide by zero
|
||||||
|
if seconds == 0:
|
||||||
|
seconds = 1
|
||||||
return (
|
return (
|
||||||
len([t for t in self._timestamps if t > (now - last_n_seconds)]) / seconds
|
len([t for t in self._timestamps if t > (now - last_n_seconds)]) / seconds
|
||||||
)
|
)
|
||||||
@ -601,6 +604,7 @@ def add_mask(mask, mask_img):
|
|||||||
)
|
)
|
||||||
cv2.fillPoly(mask_img, pts=[contour], color=(0))
|
cv2.fillPoly(mask_img, pts=[contour], color=(0))
|
||||||
|
|
||||||
|
|
||||||
def load_labels(path, encoding="utf-8"):
|
def load_labels(path, encoding="utf-8"):
|
||||||
"""Loads labels from file (with or without index numbers).
|
"""Loads labels from file (with or without index numbers).
|
||||||
Args:
|
Args:
|
||||||
@ -620,6 +624,7 @@ def load_labels(path, encoding="utf-8"):
|
|||||||
else:
|
else:
|
||||||
return {index: line.strip() for index, line in enumerate(lines)}
|
return {index: line.strip() for index, line in enumerate(lines)}
|
||||||
|
|
||||||
|
|
||||||
class FrameManager(ABC):
|
class FrameManager(ABC):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def create(self, name, size) -> AnyStr:
|
def create(self, name, size) -> AnyStr:
|
||||||
|
Loading…
Reference in New Issue
Block a user