diff --git a/frigate/api/review.py b/frigate/api/review.py index db8eb3d82..e5f833bb3 100644 --- a/frigate/api/review.py +++ b/frigate/api/review.py @@ -530,7 +530,11 @@ def motion_activity(params: ReviewActivityMotionQueryParams = Depends()): .to_frame() ) cameras = df["camera"].resample(f"{scale}s").agg(lambda x: ",".join(set(x))) - calibrations = df["is_calibrating"].resample(f"{scale}s").apply(lambda x: all(x)) + calibrations = ( + df["is_calibrating"] + .resample(f"{scale}s") + .apply(lambda x: (len(x) > 0 and all(x))) + ) df = motion.join(cameras).join(calibrations) length = df.shape[0] diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.py index a5f49609f..b106bbe72 100644 --- a/frigate/record/maintainer.py +++ b/frigate/record/maintainer.py @@ -388,9 +388,15 @@ class RecordingMaintainer(threading.Thread): ] ) motion_count += len(frame[2]) - is_calibrating += frame[3] + is_calibrating = is_calibrating or frame[3] region_count += len(frame[4]) + # if there is any motion frame without calibrating, consider the section as non-calibrating. + is_calibrating = is_calibrating and not any( + len(frame[2]) > 0 and not frame[3] + for frame in self.object_recordings_info[camera] + ) + audio_values = [] for frame in self.audio_recordings_info[camera]: # frame is after end time of segment diff --git a/web/src/hooks/use-motion-segment-utils.ts b/web/src/hooks/use-motion-segment-utils.ts index cf05e9b70..1a9f08623 100644 --- a/web/src/hooks/use-motion-segment-utils.ts +++ b/web/src/hooks/use-motion-segment-utils.ts @@ -57,7 +57,16 @@ export const useMotionSegmentUtils = ( (acc, curr) => acc + (curr.motion ?? 0), 0, ); - const isCalibrating = matchingEvents.every((curr) => curr.is_calibrating); + // A segment is considered calibration only when there is no "non-calibrating" motion. + const isCalibrating = + matchingEvents.some((curr) => curr.is_calibrating) && + matchingEvents.every( + (curr) => + !curr.motion || + (curr.motion > 0 && + curr.is_calibrating != undefined && + curr.is_calibrating), + ); return { totalMotion: totalMotion, isCalibrating: isCalibrating }; },