gallery manager WIP

This commit is contained in:
Alex Bezdieniezhnykh
2024-08-30 18:15:02 +03:00
parent 8d8a78c9f5
commit 9436e96d81
13 changed files with 402 additions and 157 deletions
+20 -1
View File
@@ -10,10 +10,13 @@ namespace Azaion.Annotator.DTO;
public class Config
{
public const string ThumbnailPrefix = "_thumb";
public string VideosDirectory { get; set; }
public string LabelsDirectory { get; set; }
public string ImagesDirectory { get; set; }
public string ResultsDirectory { get; set; }
public string ThumbnailsDirectory { get; set; }
public List<AnnotationClass> AnnotationClasses { get; set; } = [];
@@ -31,6 +34,14 @@ public class Config
public List<string> VideoFormats { get; set; }
public List<string> ImageFormats { get; set; }
public ThumbnailConfig ThumbnailConfig { get; set; }
}
public class ThumbnailConfig
{
public Size Size { get; set; }
public int Border { get; set; }
}
public interface IConfigRepository
@@ -48,9 +59,11 @@ public class FileConfigRepository(ILogger<FileConfigRepository> logger) : IConfi
private const string DEFAULT_LABELS_DIR = "labels";
private const string DEFAULT_IMAGES_DIR = "images";
private const string DEFAULT_RESULTS_DIR = "results";
private const string DEFAULT_THUMBNAILS_DIR = "thumbnails";
private static readonly Size DefaultWindowSize = new(1280, 720);
private static readonly Point DefaultWindowLocation = new(100, 100);
private static readonly Size DefaultThumbnailSize = new(240, 135);
private static readonly List<string> DefaultVideoFormats = ["mp4", "mov", "avi"];
private static readonly List<string> DefaultImageFormats = ["jpg", "jpeg", "png", "bmp"];
@@ -68,13 +81,19 @@ public class FileConfigRepository(ILogger<FileConfigRepository> logger) : IConfi
LabelsDirectory = Path.Combine(exePath, DEFAULT_LABELS_DIR),
ImagesDirectory = Path.Combine(exePath, DEFAULT_IMAGES_DIR),
ResultsDirectory = Path.Combine(exePath, DEFAULT_RESULTS_DIR),
ThumbnailsDirectory = Path.Combine(exePath, DEFAULT_THUMBNAILS_DIR),
WindowLocation = DefaultWindowLocation,
WindowSize = DefaultWindowSize,
ShowHelpOnStart = true,
VideoFormats = DefaultVideoFormats,
ImageFormats = DefaultImageFormats
ImageFormats = DefaultImageFormats,
ThumbnailConfig = new ThumbnailConfig
{
Size = DefaultThumbnailSize,
Border = 10
}
};
}
var str = File.ReadAllText(CONFIG_PATH);
+4 -1
View File
@@ -9,11 +9,14 @@ public class FormState
public SelectionState SelectionState { get; set; } = SelectionState.None;
public MediaFileInfo? CurrentMedia { get; set; }
public Size CurrentVideoSize { get; set; }
public string VideoName => string.IsNullOrEmpty(CurrentMedia?.Name)
? ""
: Path.GetFileNameWithoutExtension(CurrentMedia.Name).Replace(" ", "");
public string CurrentMrl { get; set; }
public Size CurrentVideoSize { get; set; }
public TimeSpan CurrentVideoLength { get; set; }
public int CurrentVolume { get; set; } = 100;
public ObservableCollection<AnnotationResult> AnnotationResults { get; set; } = [];
+12 -1
View File
@@ -1,4 +1,5 @@
using System.Globalization;
using System.IO;
using System.Windows;
using Newtonsoft.Json;
@@ -146,7 +147,17 @@ public class YoloLabel : Label
return null;
}
}
public static async Task<List<YoloLabel>> ReadFromFile(string filename, CancellationToken cancellationToken)
{
var str = await File.ReadAllTextAsync(filename, cancellationToken);
return str.Split(Environment.NewLine)
.Select(Parse)
.Where(ann => ann != null)
.ToList()!;
}
public override string ToString() => $"{ClassNumber} {CenterX:F5} {CenterY:F5} {Width:F5} {Height:F5}".Replace(',', '.');
}