Fixes to determine if a segment is to be considered as calibrating.

This commit is contained in:
p-boon 2025-04-03 19:19:13 +02:00
parent 5af9fa2d2f
commit 71c498b992
3 changed files with 22 additions and 3 deletions

View File

@ -530,7 +530,11 @@ def motion_activity(params: ReviewActivityMotionQueryParams = Depends()):
.to_frame() .to_frame()
) )
cameras = df["camera"].resample(f"{scale}s").agg(lambda x: ",".join(set(x))) 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) df = motion.join(cameras).join(calibrations)
length = df.shape[0] length = df.shape[0]

View File

@ -388,9 +388,15 @@ class RecordingMaintainer(threading.Thread):
] ]
) )
motion_count += len(frame[2]) motion_count += len(frame[2])
is_calibrating += frame[3] is_calibrating = is_calibrating or frame[3]
region_count += len(frame[4]) 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 = [] audio_values = []
for frame in self.audio_recordings_info[camera]: for frame in self.audio_recordings_info[camera]:
# frame is after end time of segment # frame is after end time of segment

View File

@ -57,7 +57,16 @@ export const useMotionSegmentUtils = (
(acc, curr) => acc + (curr.motion ?? 0), (acc, curr) => acc + (curr.motion ?? 0),
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 }; return { totalMotion: totalMotion, isCalibrating: isCalibrating };
}, },