add separate video loader class

This commit is contained in:
Bart Moyaers
2019-11-29 10:32:37 +01:00
parent 8ac9d97398
commit c4170aa3b5
4 changed files with 117 additions and 55 deletions

27
recording_grouper.py Normal file
View File

@@ -0,0 +1,27 @@
from data.library import ArkiteData
from string import digits as DIGITS
class RecordingGrouper:
def __init__(self, data: ArkiteData):
self.data = data
def getRecordings(self):
for detection in self.data.detections(self.data.use_cases()):
for recording in detection.recordings():
yield recording
def getRecordingGroups(self):
groups = []
for recording in self.getRecordings():
# Check if last char is digit
name = recording.name
if name[-1] in DIGITS:
# Remove last two chars:
splitname = name[:-2]
group = next((x for x in groups if x[0] == splitname), None)
if group is not None:
group[1].append(recording)
else:
groups.append((splitname, [recording]))
return groups