mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
Improve scaling of graph motion activity
This commit is contained in:
parent
ba1b2158dd
commit
48b672e4b4
@ -784,10 +784,11 @@ def hourly_timeline_activity(camera_name: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
data_type = recording.objects > 0
|
data_type = recording.objects > 0
|
||||||
|
count = recording.motion + recording.objects
|
||||||
hours[int(key.timestamp())].append(
|
hours[int(key.timestamp())].append(
|
||||||
[
|
[
|
||||||
recording.start_time + (recording.duration / 2),
|
recording.start_time + (recording.duration / 2),
|
||||||
max(recording.motion, recording.objects),
|
0 if count == 0 else np.log2(count),
|
||||||
data_type,
|
data_type,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@ -801,7 +802,6 @@ def hourly_timeline_activity(camera_name: str):
|
|||||||
df.set_index(["date"], inplace=True)
|
df.set_index(["date"], inplace=True)
|
||||||
|
|
||||||
# normalize data
|
# normalize data
|
||||||
df["count"] = np.clip(np.log10(df["count"], where=df["count"] > 0), None, 10)
|
|
||||||
df = df.resample("T").mean().fillna(0)
|
df = df.resample("T").mean().fillna(0)
|
||||||
|
|
||||||
# change types for output
|
# change types for output
|
||||||
|
|||||||
@ -108,6 +108,15 @@ class TimelineProcessor(threading.Thread):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# update sub labels for existing entries that haven't been added yet
|
||||||
|
if (
|
||||||
|
prev_event_data != None
|
||||||
|
and prev_event_data["sub_label"] != event_data["sub_label"]
|
||||||
|
and event_id in self.pre_event_cache.keys()
|
||||||
|
):
|
||||||
|
for e in self.pre_event_cache[event_id]:
|
||||||
|
e[Timeline.data]["sub_label"] = event_data["sub_label"]
|
||||||
|
|
||||||
if event_type == "start":
|
if event_type == "start":
|
||||||
timeline_entry[Timeline.class_type] = "visible"
|
timeline_entry[Timeline.class_type] = "visible"
|
||||||
save = True
|
save = True
|
||||||
|
|||||||
@ -48,7 +48,7 @@ export default function TimelineGraph({
|
|||||||
grid: {
|
grid: {
|
||||||
show: false,
|
show: false,
|
||||||
padding: {
|
padding: {
|
||||||
bottom: 20,
|
bottom: 2,
|
||||||
top: -12,
|
top: -12,
|
||||||
left: -20,
|
left: -20,
|
||||||
right: 0,
|
right: 0,
|
||||||
|
|||||||
@ -143,8 +143,8 @@ function ActivityScrubber({
|
|||||||
|
|
||||||
const timelineInstance = new VisTimeline(
|
const timelineInstance = new VisTimeline(
|
||||||
divElement,
|
divElement,
|
||||||
items as DataItem[],
|
(items || []) as DataItem[],
|
||||||
groups as DataGroup[],
|
(groups || []) as DataGroup[],
|
||||||
timelineOptions
|
timelineOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -6,8 +6,23 @@ export function getHourlyTimelineData(
|
|||||||
detailLevel: string
|
detailLevel: string
|
||||||
): CardsData {
|
): CardsData {
|
||||||
const cards: CardsData = {};
|
const cards: CardsData = {};
|
||||||
|
const allHours: { [key: string]: Timeline[] } = {};
|
||||||
|
|
||||||
timelinePages.forEach((hourlyTimeline) => {
|
timelinePages.forEach((hourlyTimeline) => {
|
||||||
Object.keys(hourlyTimeline["hours"])
|
Object.entries(hourlyTimeline.hours).forEach(([key, values]) => {
|
||||||
|
if (key in allHours) {
|
||||||
|
// only occurs when multiple pages contain elements in the same hour
|
||||||
|
allHours[key] = allHours[key]
|
||||||
|
.concat(values)
|
||||||
|
.sort((a, b) => a.timestamp - b.timestamp);
|
||||||
|
} else {
|
||||||
|
allHours[key] = values;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.keys(allHours)
|
||||||
|
.sort((a, b) => a.localeCompare(b))
|
||||||
.reverse()
|
.reverse()
|
||||||
.forEach((hour) => {
|
.forEach((hour) => {
|
||||||
const day = new Date(parseInt(hour) * 1000);
|
const day = new Date(parseInt(hour) * 1000);
|
||||||
@ -18,7 +33,7 @@ export function getHourlyTimelineData(
|
|||||||
// which allows us to know what items to keep depending on detail level
|
// which allows us to know what items to keep depending on detail level
|
||||||
const sourceToTypes: { [key: string]: string[] } = {};
|
const sourceToTypes: { [key: string]: string[] } = {};
|
||||||
let cardTypeStart: { [camera: string]: number } = {};
|
let cardTypeStart: { [camera: string]: number } = {};
|
||||||
Object.values(hourlyTimeline["hours"][hour]).forEach((i) => {
|
Object.values(allHours[hour]).forEach((i) => {
|
||||||
if (i.timestamp > (cardTypeStart[i.camera] ?? 0) + GROUP_SECONDS) {
|
if (i.timestamp > (cardTypeStart[i.camera] ?? 0) + GROUP_SECONDS) {
|
||||||
cardTypeStart[i.camera] = i.timestamp;
|
cardTypeStart[i.camera] = i.timestamp;
|
||||||
}
|
}
|
||||||
@ -41,7 +56,7 @@ export function getHourlyTimelineData(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let cardStart: { [camera: string]: number } = {};
|
let cardStart: { [camera: string]: number } = {};
|
||||||
Object.values(hourlyTimeline["hours"][hour]).forEach((i) => {
|
Object.values(allHours[hour]).forEach((i) => {
|
||||||
if (i.timestamp > (cardStart[i.camera] ?? 0) + GROUP_SECONDS) {
|
if (i.timestamp > (cardStart[i.camera] ?? 0) + GROUP_SECONDS) {
|
||||||
cardStart[i.camera] = i.timestamp;
|
cardStart[i.camera] = i.timestamp;
|
||||||
}
|
}
|
||||||
@ -109,7 +124,6 @@ export function getHourlyTimelineData(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return cards;
|
return cards;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,7 +162,6 @@ export default function DesktopTimelineView({
|
|||||||
{isSelected ? (
|
{isSelected ? (
|
||||||
<div className="p-2 relative bg-secondary bg-opacity-30 rounded-md">
|
<div className="p-2 relative bg-secondary bg-opacity-30 rounded-md">
|
||||||
<ActivityScrubber
|
<ActivityScrubber
|
||||||
items={[]}
|
|
||||||
timeBars={
|
timeBars={
|
||||||
isSelected
|
isSelected
|
||||||
? [
|
? [
|
||||||
@ -180,7 +179,10 @@ export default function DesktopTimelineView({
|
|||||||
snap: null,
|
snap: null,
|
||||||
min: new Date(timeline.range.start * 1000),
|
min: new Date(timeline.range.start * 1000),
|
||||||
max: new Date(timeline.range.end * 1000),
|
max: new Date(timeline.range.end * 1000),
|
||||||
|
start: new Date(timeline.range.start * 1000),
|
||||||
|
end: new Date(timeline.range.end * 1000),
|
||||||
zoomable: false,
|
zoomable: false,
|
||||||
|
height: "120px",
|
||||||
}}
|
}}
|
||||||
timechangeHandler={(data) => {
|
timechangeHandler={(data) => {
|
||||||
controllerRef.current?.scrubToTimestamp(
|
controllerRef.current?.scrubToTimestamp(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user