mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-06-21 03:41:55 +03:00
replace motion activity resample apply/agg lambdas with vectorized max() and first() (#23383)
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / Assemble and push default build (push) Blocked by required conditions
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / Assemble and push default build (push) Blocked by required conditions
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
This commit is contained in:
parent
570e21340a
commit
db9e64c598
@ -605,9 +605,10 @@ def motion_activity(
|
|||||||
if not filtered:
|
if not filtered:
|
||||||
return JSONResponse(content=[])
|
return JSONResponse(content=[])
|
||||||
camera_list = list(filtered)
|
camera_list = list(filtered)
|
||||||
clauses.append((Recordings.camera << camera_list))
|
|
||||||
else:
|
else:
|
||||||
clauses.append((Recordings.camera << allowed_cameras))
|
camera_list = list(allowed_cameras)
|
||||||
|
|
||||||
|
clauses.append((Recordings.camera << camera_list))
|
||||||
|
|
||||||
data: list[Recordings] = (
|
data: list[Recordings] = (
|
||||||
Recordings.select(
|
Recordings.select(
|
||||||
@ -635,13 +636,11 @@ def motion_activity(
|
|||||||
df.set_index(["start_time"], inplace=True)
|
df.set_index(["start_time"], inplace=True)
|
||||||
|
|
||||||
# normalize data
|
# normalize data
|
||||||
motion = (
|
motion = df["motion"].resample(f"{scale}s").max().fillna(0.0).to_frame()
|
||||||
df["motion"]
|
|
||||||
.resample(f"{scale}s")
|
if len(camera_list) == 1:
|
||||||
.apply(lambda x: max(x, key=abs, default=0.0))
|
cameras = df["camera"].resample(f"{scale}s").first().fillna("")
|
||||||
.fillna(0.0)
|
else:
|
||||||
.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)))
|
||||||
df = motion.join(cameras)
|
df = motion.join(cameras)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user