mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Include which cameras detected motion during aggregated data (#10663)
This commit is contained in:
parent
7b64091128
commit
258cd5b6d7
@ -358,6 +358,7 @@ def motion_activity():
|
|||||||
)
|
)
|
||||||
|
|
||||||
clauses = [(Recordings.start_time > after) & (Recordings.end_time < before)]
|
clauses = [(Recordings.start_time > after) & (Recordings.end_time < before)]
|
||||||
|
clauses.append((Recordings.motion > 0))
|
||||||
|
|
||||||
if cameras != "all":
|
if cameras != "all":
|
||||||
camera_list = cameras.split(",")
|
camera_list = cameras.split(",")
|
||||||
@ -365,6 +366,7 @@ def motion_activity():
|
|||||||
|
|
||||||
data: list[Recordings] = (
|
data: list[Recordings] = (
|
||||||
Recordings.select(
|
Recordings.select(
|
||||||
|
Recordings.camera,
|
||||||
Recordings.start_time,
|
Recordings.start_time,
|
||||||
Recordings.motion,
|
Recordings.motion,
|
||||||
)
|
)
|
||||||
@ -378,18 +380,22 @@ def motion_activity():
|
|||||||
scale = request.args.get("scale", type=int, default=30)
|
scale = request.args.get("scale", type=int, default=30)
|
||||||
|
|
||||||
# resample data using pandas to get activity on scaled basis
|
# resample data using pandas to get activity on scaled basis
|
||||||
df = pd.DataFrame(data, columns=["start_time", "motion"])
|
df = pd.DataFrame(data, columns=["start_time", "motion", "camera"])
|
||||||
|
|
||||||
# set date as datetime index
|
# set date as datetime index
|
||||||
df["start_time"] = pd.to_datetime(df["start_time"], unit="s")
|
df["start_time"] = pd.to_datetime(df["start_time"], unit="s")
|
||||||
df.set_index(["start_time"], inplace=True)
|
df.set_index(["start_time"], inplace=True)
|
||||||
|
|
||||||
# normalize data
|
# normalize data
|
||||||
df = (
|
motion = (
|
||||||
df.resample(f"{scale}S")
|
df["motion"]
|
||||||
|
.resample(f"{scale}S")
|
||||||
.apply(lambda x: max(x, key=abs, default=0.0))
|
.apply(lambda x: max(x, key=abs, default=0.0))
|
||||||
.fillna(0.0)
|
.fillna(0.0)
|
||||||
|
.to_frame()
|
||||||
)
|
)
|
||||||
|
cameras = df["camera"].resample(f"{scale}S").agg(lambda x: ",".join(set(x)))
|
||||||
|
df = motion.join(cameras)
|
||||||
|
|
||||||
length = df.shape[0]
|
length = df.shape[0]
|
||||||
chunk = int(60 * (60 / scale))
|
chunk = int(60 * (60 / scale))
|
||||||
|
Loading…
Reference in New Issue
Block a user