mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:46:30 +00:00
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using System.Windows;
|
|
using Azaion.Annotator.DTO;
|
|
|
|
namespace Azaion.Annotator;
|
|
|
|
public partial class DatasetExplorer
|
|
{
|
|
private readonly Config _config;
|
|
|
|
public ObservableCollection<ThumbnailDto> ThumbnailsDtos { get; set; } = new();
|
|
|
|
public DatasetExplorer(Config config)
|
|
{
|
|
_config = config;
|
|
|
|
InitializeComponent();
|
|
DataContext = this;
|
|
Loaded += async (sender, args) => await LoadThumbnails();
|
|
|
|
Closing += (sender, args) =>
|
|
{
|
|
args.Cancel = true;
|
|
Visibility = Visibility.Hidden;
|
|
};
|
|
}
|
|
|
|
private async Task LoadThumbnails()
|
|
{
|
|
if (!Directory.Exists(_config.ThumbnailsDirectory))
|
|
return;
|
|
|
|
var thumbnails = Directory.GetFiles(_config.ThumbnailsDirectory, "*.jpg");
|
|
|
|
foreach (var thumbnail in thumbnails)
|
|
{
|
|
var name = Path.GetFileNameWithoutExtension(thumbnail)[..^Config.ThumbnailPrefix.Length];
|
|
var imageName = Path.Combine(_config.ImagesDirectory, name);
|
|
foreach (var imageFormat in _config.ImageFormats)
|
|
{
|
|
imageName = $"{imageName}.{imageFormat}";
|
|
if (File.Exists(imageName))
|
|
break;
|
|
}
|
|
|
|
ThumbnailsDtos.Add(new ThumbnailDto
|
|
{
|
|
ThumbnailPath = thumbnail,
|
|
ImagePath = imageName,
|
|
LabelPath = Path.Combine(_config.LabelsDirectory, $"{name}.txt"),
|
|
});
|
|
}
|
|
}
|
|
} |