Files
opencv_python_tests/recording_grouper.py
2019-11-29 10:32:37 +01:00

27 lines
907 B
Python

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