2021-06-07 03:24:36 +02:00
|
|
|
from numpy import unique
|
2022-04-16 17:40:04 +02:00
|
|
|
from peewee import (
|
|
|
|
Model,
|
|
|
|
CharField,
|
|
|
|
DateTimeField,
|
|
|
|
FloatField,
|
|
|
|
BooleanField,
|
|
|
|
TextField,
|
|
|
|
IntegerField,
|
|
|
|
)
|
2022-04-18 13:52:13 +02:00
|
|
|
from playhouse.sqlite_ext import JSONField
|
2020-11-01 15:06:15 +01:00
|
|
|
|
2020-11-04 13:31:25 +01:00
|
|
|
|
2022-04-16 17:40:04 +02:00
|
|
|
class Event(Model): # type: ignore[misc]
|
2020-11-01 15:06:15 +01:00
|
|
|
id = CharField(null=False, primary_key=True, max_length=30)
|
|
|
|
label = CharField(index=True, max_length=20)
|
2023-05-05 00:59:44 +02:00
|
|
|
sub_label = CharField(max_length=100, null=True)
|
2020-11-01 15:06:15 +01:00
|
|
|
camera = CharField(index=True, max_length=20)
|
|
|
|
start_time = DateTimeField()
|
|
|
|
end_time = DateTimeField()
|
2023-04-30 19:07:14 +02:00
|
|
|
top_score = (
|
|
|
|
FloatField()
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
|
|
|
score = (
|
|
|
|
FloatField()
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
2020-11-01 15:06:15 +01:00
|
|
|
false_positive = BooleanField()
|
2020-11-04 13:31:25 +01:00
|
|
|
zones = JSONField()
|
2020-11-15 15:50:49 +01:00
|
|
|
thumbnail = TextField()
|
2020-12-24 14:47:27 +01:00
|
|
|
has_clip = BooleanField(default=True)
|
|
|
|
has_snapshot = BooleanField(default=True)
|
2023-04-30 19:07:14 +02:00
|
|
|
region = (
|
|
|
|
JSONField()
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
|
|
|
box = (
|
|
|
|
JSONField()
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
|
|
|
area = (
|
|
|
|
IntegerField()
|
|
|
|
) # TODO remove when columns can be dropped without rebuilding table
|
2022-02-22 05:03:01 +01:00
|
|
|
retain_indefinitely = BooleanField(default=False)
|
2022-04-10 15:25:18 +02:00
|
|
|
ratio = FloatField(default=1.0)
|
2022-04-03 22:00:11 +02:00
|
|
|
plus_id = CharField(max_length=30)
|
2023-04-24 14:24:28 +02:00
|
|
|
model_hash = CharField(max_length=32)
|
|
|
|
detector_type = CharField(max_length=32)
|
|
|
|
model_type = CharField(max_length=32)
|
2023-04-30 19:07:14 +02:00
|
|
|
data = JSONField() # ex: tracked object box, region, etc.
|
2021-06-07 03:24:36 +02:00
|
|
|
|
|
|
|
|
2023-04-23 17:45:19 +02:00
|
|
|
class Timeline(Model): # type: ignore[misc]
|
|
|
|
timestamp = DateTimeField()
|
|
|
|
camera = CharField(index=True, max_length=20)
|
|
|
|
source = CharField(index=True, max_length=20) # ex: tracked object, audio, external
|
|
|
|
source_id = CharField(index=True, max_length=30)
|
|
|
|
class_type = CharField(max_length=50) # ex: entered_zone, audio_heard
|
|
|
|
data = JSONField() # ex: tracked object id, region, box, etc.
|
|
|
|
|
|
|
|
|
2022-04-16 17:40:04 +02:00
|
|
|
class Recordings(Model): # type: ignore[misc]
|
2021-06-07 03:24:36 +02:00
|
|
|
id = CharField(null=False, primary_key=True, max_length=30)
|
|
|
|
camera = CharField(index=True, max_length=20)
|
|
|
|
path = CharField(unique=True)
|
|
|
|
start_time = DateTimeField()
|
|
|
|
end_time = DateTimeField()
|
|
|
|
duration = FloatField()
|
2021-12-11 20:47:59 +01:00
|
|
|
motion = IntegerField(null=True)
|
|
|
|
objects = IntegerField(null=True)
|
2022-10-09 13:28:26 +02:00
|
|
|
segment_size = FloatField(default=0) # this should be stored as MB
|