make thumbnail generating multithread

fix the bug with open video
add class distribution chart
This commit is contained in:
Alex Bezdieniezhnykh
2024-09-25 21:46:07 +03:00
parent 742f1ffee9
commit 22d4493d86
11 changed files with 215 additions and 50 deletions
+13 -7
View File
@@ -248,25 +248,25 @@ public partial class MainWindow
foreach (var file in labelFiles)
{
var name = Path.GetFileNameWithoutExtension(file.Name);
var time = _formState.GetTime(name)!.Value;
var time = _formState.GetTime(name);
await AddAnnotation(time, await YoloLabel.ReadFromFile(file.FullName));
}
}
public async Task AddAnnotation(TimeSpan time, List<YoloLabel> annotations)
public async Task AddAnnotation(TimeSpan? time, List<YoloLabel> annotations)
{
var fName = _formState.GetTimeName(time);
var previousAnnotations = Annotations.Query(time);
var timeValue = time ?? TimeSpan.FromMinutes(0);
var previousAnnotations = Annotations.Query(timeValue);
Annotations.Remove(previousAnnotations);
Annotations.Add(time.Subtract(_thresholdBefore), time.Add(_thresholdAfter), annotations);
Annotations.Add(timeValue.Subtract(_thresholdBefore), timeValue.Add(_thresholdAfter), annotations);
var existingResult = _formState.AnnotationResults.FirstOrDefault(x => x.Time == time);
if (existingResult != null)
_formState.AnnotationResults.Remove(existingResult);
_formState.AnnotationResults.Add(new AnnotationResult(time, fName, annotations, _config));
_formState.AnnotationResults.Add(new AnnotationResult(timeValue, fName, annotations, _config));
await File.WriteAllTextAsync($"{_config.ResultsDirectory}/{fName}.json", JsonConvert.SerializeObject(_formState.AnnotationResults));
}
@@ -277,7 +277,13 @@ public partial class MainWindow
return;
var labelNames = new DirectoryInfo(_config.LabelsDirectory).GetFiles()
.Select(x => x.Name[..^11])
.Select(x =>
{
var name = Path.GetFileNameWithoutExtension(x.Name);
return name.Length > 8
? name[..^7]
: name;
})
.GroupBy(x => x)
.Select(gr => gr.Key)
.ToDictionary(x => x);