mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 08:36:29 +00:00
add MediaHash. Step1
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
@@ -21,6 +22,7 @@ using Microsoft.WindowsAPICodePack.Dialogs;
|
|||||||
using Size = System.Windows.Size;
|
using Size = System.Windows.Size;
|
||||||
using IntervalTree;
|
using IntervalTree;
|
||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
|
using LinqToDB.Data;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using MediaPlayer = LibVLCSharp.Shared.MediaPlayer;
|
using MediaPlayer = LibVLCSharp.Shared.MediaPlayer;
|
||||||
@@ -40,7 +42,6 @@ public partial class Annotator
|
|||||||
private readonly ILogger<Annotator> _logger;
|
private readonly ILogger<Annotator> _logger;
|
||||||
private readonly IDbFactory _dbFactory;
|
private readonly IDbFactory _dbFactory;
|
||||||
private readonly IInferenceService _inferenceService;
|
private readonly IInferenceService _inferenceService;
|
||||||
private readonly IInferenceClient _inferenceClient;
|
|
||||||
|
|
||||||
private bool _suspendLayout;
|
private bool _suspendLayout;
|
||||||
private bool _gpsPanelVisible;
|
private bool _gpsPanelVisible;
|
||||||
@@ -52,14 +53,15 @@ public partial class Annotator
|
|||||||
private readonly TimeSpan _thresholdBefore = TimeSpan.FromMilliseconds(50);
|
private readonly TimeSpan _thresholdBefore = TimeSpan.FromMilliseconds(50);
|
||||||
private readonly TimeSpan _thresholdAfter = TimeSpan.FromMilliseconds(150);
|
private readonly TimeSpan _thresholdAfter = TimeSpan.FromMilliseconds(150);
|
||||||
|
|
||||||
public ObservableCollection<MediaFileInfo> AllMediaFiles { get; set; } = new();
|
public ObservableCollection<MediaFile> AllMediaFiles { get; set; } = new();
|
||||||
private ObservableCollection<MediaFileInfo> FilteredMediaFiles { get; set; } = new();
|
private ObservableCollection<MediaFile> FilteredMediaFiles { get; set; } = new();
|
||||||
public Dictionary<string, MediaFileInfo> MediaFilesDict = new();
|
public Dictionary<string, MediaFile> MediaFilesDict = new();
|
||||||
|
|
||||||
public IntervalTree<TimeSpan, Annotation> TimedAnnotations { get; set; } = new();
|
public IntervalTree<TimeSpan, Annotation> TimedAnnotations { get; set; } = new();
|
||||||
public string MainTitle { get; set; }
|
public string MainTitle { get; set; }
|
||||||
|
|
||||||
public CameraConfig Camera => _appConfig?.CameraConfig ?? new CameraConfig();
|
public CameraConfig Camera => _appConfig?.CameraConfig ?? new CameraConfig();
|
||||||
|
private static readonly Guid ReloadTaskId = Guid.NewGuid();
|
||||||
|
|
||||||
public Annotator(
|
public Annotator(
|
||||||
IConfigUpdater configUpdater,
|
IConfigUpdater configUpdater,
|
||||||
@@ -86,7 +88,6 @@ public partial class Annotator
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_dbFactory = dbFactory;
|
_dbFactory = dbFactory;
|
||||||
_inferenceService = inferenceService;
|
_inferenceService = inferenceService;
|
||||||
_inferenceClient = inferenceClient;
|
|
||||||
|
|
||||||
// Ensure bindings (e.g., Camera) resolve immediately
|
// Ensure bindings (e.g., Camera) resolve immediately
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
@@ -294,9 +295,14 @@ public partial class Annotator
|
|||||||
TimedAnnotations.Clear();
|
TimedAnnotations.Clear();
|
||||||
Editor.RemoveAllAnns();
|
Editor.RemoveAllAnns();
|
||||||
|
|
||||||
|
var mediaHash = _formState.CurrentMedia?.Hash;
|
||||||
|
var mediaName = _formState.CurrentMedia?.Name;
|
||||||
|
|
||||||
var annotations = await _dbFactory.Run(async db =>
|
var annotations = await _dbFactory.Run(async db =>
|
||||||
await db.Annotations.LoadWith(x => x.Detections)
|
await db.Annotations.LoadWith(x => x.Detections)
|
||||||
.Where(x => x.OriginalMediaName == _formState.MediaName)
|
.Where(x =>
|
||||||
|
(!string.IsNullOrEmpty(mediaHash) && x.MediaHash == mediaHash) ||
|
||||||
|
(x.MediaHash == null && x.OriginalMediaName == mediaName))
|
||||||
.OrderBy(x => x.Time)
|
.OrderBy(x => x.Time)
|
||||||
.ToListAsync(token: _mainCancellationSource.Token));
|
.ToListAsync(token: _mainCancellationSource.Token));
|
||||||
|
|
||||||
@@ -304,7 +310,6 @@ public partial class Annotator
|
|||||||
_formState.AnnotationResults.Clear();
|
_formState.AnnotationResults.Clear();
|
||||||
foreach (var ann in annotations)
|
foreach (var ann in annotations)
|
||||||
{
|
{
|
||||||
// Duplicate for speed
|
|
||||||
TimedAnnotations.Add(ann.Time.Subtract(_thresholdBefore), ann.Time.Add(_thresholdAfter), ann);
|
TimedAnnotations.Add(ann.Time.Subtract(_thresholdBefore), ann.Time.Add(_thresholdAfter), ann);
|
||||||
_formState.AnnotationResults.Add(ann);
|
_formState.AnnotationResults.Add(ann);
|
||||||
}
|
}
|
||||||
@@ -344,55 +349,109 @@ public partial class Annotator
|
|||||||
_formState.AnnotationResults.Insert(index, annotation);
|
_formState.AnnotationResults.Insert(index, annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ReloadFiles()
|
public void ReloadFilesThrottled()
|
||||||
|
{
|
||||||
|
ThrottleExt.Throttle(async () =>
|
||||||
|
{
|
||||||
|
await ReloadFiles();
|
||||||
|
}, ReloadTaskId, TimeSpan.FromSeconds(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ReloadFiles()
|
||||||
{
|
{
|
||||||
var dir = new DirectoryInfo(_appConfig?.DirectoriesConfig.VideosDirectory ?? Constants.DEFAULT_VIDEO_DIR);
|
var dir = new DirectoryInfo(_appConfig?.DirectoriesConfig.VideosDirectory ?? Constants.DEFAULT_VIDEO_DIR);
|
||||||
if (!dir.Exists)
|
if (!dir.Exists)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var videoFiles = dir.GetFiles((_appConfig?.AnnotationConfig.VideoFormats ?? Constants.DefaultVideoFormats)
|
var folderFiles = dir.GetFiles(Constants.DefaultVideoFormats.Concat(Constants.DefaultImageFormats).ToArray())
|
||||||
.ToArray()).Select(x =>
|
.Select(x => x.FullName)
|
||||||
{
|
.Select(x => new MediaFile(x))
|
||||||
var media = new Media(_libVlc, x.FullName);
|
.GroupBy(x => x.Hash)
|
||||||
media.Parse();
|
.ToDictionary(x => x.Key, v => v.First());
|
||||||
var fInfo = new MediaFileInfo
|
|
||||||
{
|
|
||||||
Name = x.Name,
|
|
||||||
Path = x.FullName,
|
|
||||||
MediaType = MediaTypes.Video
|
|
||||||
};
|
|
||||||
media.ParsedChanged += (_, _) => fInfo.Duration = TimeSpan.FromMilliseconds(media.Duration);
|
|
||||||
return fInfo;
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
var imageFiles = dir.GetFiles((_appConfig?.AnnotationConfig.ImageFormats ?? Constants.DefaultImageFormats).ToArray())
|
//sync with db
|
||||||
.Select(x => new MediaFileInfo
|
var dbFiles = await _dbFactory.Run(async db =>
|
||||||
{
|
await db.MediaFiles
|
||||||
Name = x.Name,
|
.Where(x => folderFiles.ContainsKey(x.Hash))
|
||||||
Path = x.FullName,
|
.ToDictionaryAsync(x => x.Hash));
|
||||||
MediaType = MediaTypes.Image
|
var newFiles = folderFiles
|
||||||
});
|
.Where(x => !dbFiles.ContainsKey(x.Key))
|
||||||
var allFiles = videoFiles.Concat(imageFiles).ToList();
|
.Select(x => x.Value)
|
||||||
|
.ToList();
|
||||||
|
if (newFiles.Count > 0)
|
||||||
|
await _dbFactory.RunWrite(async db => await db.BulkCopyAsync(newFiles));
|
||||||
|
|
||||||
var allFileNames = allFiles.Select(x => x.FName).ToList();
|
var allFiles = dbFiles.Select(x => x.Value)
|
||||||
|
.Concat(newFiles)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
var labelsDict = await _dbFactory.Run(async db =>
|
await SyncAnnotations(allFiles);
|
||||||
await db.Annotations
|
|
||||||
.GroupBy(x => x.OriginalMediaName)
|
|
||||||
.Where(x => allFileNames.Contains(x.Key))
|
|
||||||
.Select(x => x.Key)
|
|
||||||
.ToDictionaryAsync(x => x, x => x));
|
|
||||||
|
|
||||||
foreach (var mediaFile in allFiles)
|
AllMediaFiles = new ObservableCollection<MediaFile>(allFiles);
|
||||||
mediaFile.HasAnnotations = labelsDict.ContainsKey(mediaFile.FName);
|
|
||||||
|
|
||||||
AllMediaFiles = new ObservableCollection<MediaFileInfo>(allFiles);
|
|
||||||
MediaFilesDict = AllMediaFiles.GroupBy(x => x.Name)
|
MediaFilesDict = AllMediaFiles.GroupBy(x => x.Name)
|
||||||
.ToDictionary(gr => gr.Key, gr => gr.First());
|
.ToDictionary(gr => gr.Key, gr => gr.First());
|
||||||
|
var selectedIndex = LvFiles.SelectedIndex;
|
||||||
LvFiles.ItemsSource = AllMediaFiles;
|
LvFiles.ItemsSource = AllMediaFiles;
|
||||||
|
LvFiles.SelectedIndex = selectedIndex;
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task SyncAnnotations(List<MediaFile> allFiles)
|
||||||
|
{
|
||||||
|
var hashes = allFiles.Select(x => x.Hash).ToList();
|
||||||
|
var filenames = allFiles.Select(x => x.Name).ToList();
|
||||||
|
var nameHashMap = allFiles.ToDictionary(x => x.Name.ToFName(), x => x.Hash);
|
||||||
|
await _dbFactory.RunWrite(async db =>
|
||||||
|
{
|
||||||
|
var hashedAnnotations = await db.Annotations
|
||||||
|
.Where(a => hashes.Contains(a.MediaHash))
|
||||||
|
.ToDictionaryAsync(x => x.Name);
|
||||||
|
|
||||||
|
var fileNameAnnotations = await db.Annotations
|
||||||
|
.Where(a => filenames.Contains(a.OriginalMediaName))
|
||||||
|
.ToDictionaryAsync(x => x.Name);
|
||||||
|
|
||||||
|
var toUpdate = fileNameAnnotations
|
||||||
|
.Where(a => !hashedAnnotations.ContainsKey(a.Key))
|
||||||
|
.Select(a => new { a.Key, MediaHash = nameHashMap.GetValueOrDefault(a.Value.OriginalMediaName) ?? "" })
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (toUpdate.Count > 0)
|
||||||
|
{
|
||||||
|
var caseBuilder = new StringBuilder("UPDATE Annotations SET MediaHash = CASE Name ");
|
||||||
|
var parameters = new List<DataParameter>();
|
||||||
|
|
||||||
|
for (int i = 0; i < toUpdate.Count; i++)
|
||||||
|
{
|
||||||
|
caseBuilder.Append($"WHEN @name{i} THEN @hash{i} ");
|
||||||
|
parameters.Add(new DataParameter($"@name{i}", toUpdate[i].Key, DataType.NVarChar));
|
||||||
|
parameters.Add(new DataParameter($"@hash{i}", toUpdate[i].MediaHash, DataType.NVarChar));
|
||||||
|
}
|
||||||
|
|
||||||
|
caseBuilder.Append("END WHERE Name IN (");
|
||||||
|
caseBuilder.Append(string.Join(", ", Enumerable.Range(0, toUpdate.Count).Select(i => $"@name{i}")));
|
||||||
|
caseBuilder.Append(")");
|
||||||
|
|
||||||
|
await db.ExecuteAsync(caseBuilder.ToString(), parameters.ToArray());
|
||||||
|
}
|
||||||
|
var annotationMediaHashes = hashedAnnotations
|
||||||
|
.GroupBy(x => x.Value.MediaHash)
|
||||||
|
.Select(x => x.Key)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var annotationMediaNames = fileNameAnnotations
|
||||||
|
.GroupBy(x => x.Value.OriginalMediaName)
|
||||||
|
.Select(x => x.Key)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
await db.MediaFiles
|
||||||
|
.Where(m => annotationMediaHashes.Contains(m.Hash) ||
|
||||||
|
annotationMediaNames.Contains(m.Name))
|
||||||
|
.Set(m => m.Status, MediaStatus.Confirmed)
|
||||||
|
.UpdateAsync();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void OnFormClosed(object? sender, EventArgs e)
|
private void OnFormClosed(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_mainCancellationSource.Cancel();
|
_mainCancellationSource.Cancel();
|
||||||
@@ -406,11 +465,11 @@ public partial class Annotator
|
|||||||
|
|
||||||
private void OpenContainingFolder(object sender, RoutedEventArgs e)
|
private void OpenContainingFolder(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var mediaFileInfo = (sender as MenuItem)?.DataContext as MediaFileInfo;
|
var mediaFileInfo = (sender as MenuItem)?.DataContext as MediaFile;
|
||||||
if (mediaFileInfo == null)
|
if (mediaFileInfo == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Process.Start("explorer.exe", "/select,\"" + mediaFileInfo.Path +"\"");
|
Process.Start("explorer.exe", "/select,\"" + mediaFileInfo.MediaUrl +"\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SeekTo(long timeMilliseconds, bool setPause = true)
|
public void SeekTo(long timeMilliseconds, bool setPause = true)
|
||||||
@@ -446,8 +505,8 @@ public partial class Annotator
|
|||||||
|
|
||||||
private void TbFilter_OnTextChanged(object sender, TextChangedEventArgs e)
|
private void TbFilter_OnTextChanged(object sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
FilteredMediaFiles = new ObservableCollection<MediaFileInfo>(AllMediaFiles.Where(x => x.Name.ToLower().Contains(TbFilter.Text.ToLower())).ToList());
|
FilteredMediaFiles = new ObservableCollection<MediaFile>(AllMediaFiles.Where(x => x.Name.ToLower().Contains(TbFilter.Text.ToLower())).ToList());
|
||||||
MediaFilesDict = FilteredMediaFiles.ToDictionary(x => x.FName);
|
MediaFilesDict = FilteredMediaFiles.ToDictionary(x => x.Name);
|
||||||
LvFiles.ItemsSource = FilteredMediaFiles;
|
LvFiles.ItemsSource = FilteredMediaFiles;
|
||||||
LvFiles.ItemsSource = FilteredMediaFiles;
|
LvFiles.ItemsSource = FilteredMediaFiles;
|
||||||
}
|
}
|
||||||
@@ -515,7 +574,7 @@ public partial class Annotator
|
|||||||
|
|
||||||
var files = (FilteredMediaFiles.Count == 0 ? AllMediaFiles : FilteredMediaFiles)
|
var files = (FilteredMediaFiles.Count == 0 ? AllMediaFiles : FilteredMediaFiles)
|
||||||
.Skip(LvFiles.SelectedIndex)
|
.Skip(LvFiles.SelectedIndex)
|
||||||
.Select(x => x.Path)
|
.Select(x => x.MediaUrl)
|
||||||
.ToList();
|
.ToList();
|
||||||
if (files.Count == 0)
|
if (files.Count == 0)
|
||||||
return;
|
return;
|
||||||
@@ -566,15 +625,15 @@ public partial class Annotator
|
|||||||
|
|
||||||
private void DeleteMedia(object sender, RoutedEventArgs e)
|
private void DeleteMedia(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var mediaFileInfo = (sender as MenuItem)?.DataContext as MediaFileInfo;
|
var mediaFileInfo = (sender as MenuItem)?.DataContext as MediaFile;
|
||||||
if (mediaFileInfo == null)
|
if (mediaFileInfo == null)
|
||||||
return;
|
return;
|
||||||
DeleteMedia(mediaFileInfo);
|
DeleteMedia(mediaFileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteMedia(MediaFileInfo mediaFileInfo)
|
public void DeleteMedia(MediaFile mediaFile)
|
||||||
{
|
{
|
||||||
var obj = mediaFileInfo.MediaType == MediaTypes.Image
|
var obj = mediaFile.MediaType == MediaTypes.Image
|
||||||
? "цю картинку "
|
? "цю картинку "
|
||||||
: "це відео ";
|
: "це відео ";
|
||||||
var result = MessageBox.Show($"Видалити {obj}?",
|
var result = MessageBox.Show($"Видалити {obj}?",
|
||||||
@@ -582,8 +641,8 @@ public partial class Annotator
|
|||||||
if (result != MessageBoxResult.Yes)
|
if (result != MessageBoxResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
File.Delete(mediaFileInfo.Path);
|
File.Delete(mediaFile.MediaUrl);
|
||||||
AllMediaFiles.Remove(mediaFileInfo);
|
AllMediaFiles.Remove(mediaFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ public class AnnotatorEventHandler(
|
|||||||
var focusedElement = FocusManager.GetFocusedElement(mainWindow);
|
var focusedElement = FocusManager.GetFocusedElement(mainWindow);
|
||||||
if (focusedElement is ListViewItem item)
|
if (focusedElement is ListViewItem item)
|
||||||
{
|
{
|
||||||
if (item.DataContext is not MediaFileInfo mediaFileInfo)
|
if (item.DataContext is not MediaFile mediaFileInfo)
|
||||||
return;
|
return;
|
||||||
mainWindow.DeleteMedia(mediaFileInfo);
|
mainWindow.DeleteMedia(mediaFileInfo);
|
||||||
}
|
}
|
||||||
@@ -245,7 +245,7 @@ public class AnnotatorEventHandler(
|
|||||||
{
|
{
|
||||||
if (mainWindow.LvFiles.SelectedItem == null)
|
if (mainWindow.LvFiles.SelectedItem == null)
|
||||||
return;
|
return;
|
||||||
var mediaInfo = (MediaFileInfo)mainWindow.LvFiles.SelectedItem;
|
var mediaInfo = (MediaFile)mainWindow.LvFiles.SelectedItem;
|
||||||
|
|
||||||
if (formState.CurrentMedia == mediaInfo)
|
if (formState.CurrentMedia == mediaInfo)
|
||||||
return; //already loaded
|
return; //already loaded
|
||||||
@@ -261,12 +261,12 @@ public class AnnotatorEventHandler(
|
|||||||
//need to wait a bit for correct VLC playback event handling
|
//need to wait a bit for correct VLC playback event handling
|
||||||
await Task.Delay(100, ct);
|
await Task.Delay(100, ct);
|
||||||
mediaPlayer.Stop();
|
mediaPlayer.Stop();
|
||||||
mediaPlayer.Play(new Media(libVlc, mediaInfo.Path));
|
mediaPlayer.Play(new Media(libVlc, mediaInfo.MediaUrl));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
formState.BackgroundTime = TimeSpan.Zero;
|
formState.BackgroundTime = TimeSpan.Zero;
|
||||||
var image = await mediaInfo.Path.OpenImage();
|
var image = await mediaInfo.MediaUrl.OpenImage();
|
||||||
formState.CurrentMediaSize = new Size(image.PixelWidth, image.PixelHeight);
|
formState.CurrentMediaSize = new Size(image.PixelWidth, image.PixelHeight);
|
||||||
mainWindow.Editor.SetBackground(image);
|
mainWindow.Editor.SetBackground(image);
|
||||||
mediaPlayer.Stop();
|
mediaPlayer.Stop();
|
||||||
@@ -281,11 +281,10 @@ public class AnnotatorEventHandler(
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var time = formState.BackgroundTime ?? TimeSpan.FromMilliseconds(mediaPlayer.Time);
|
var time = formState.BackgroundTime ?? TimeSpan.FromMilliseconds(mediaPlayer.Time);
|
||||||
var timeName = formState.MediaName.ToTimeName(time);
|
var timeName = formState.CurrentMedia.Name.ToTimeName(time);
|
||||||
var isVideo = formState.CurrentMedia.MediaType == MediaTypes.Video;
|
var isVideo = formState.CurrentMedia.MediaType == MediaTypes.Video;
|
||||||
var imgPath = Path.Combine(dirConfig.Value.ImagesDirectory, $"{timeName}{Constants.JPG_EXT}");
|
var imgPath = Path.Combine(dirConfig.Value.ImagesDirectory, $"{timeName}{Constants.JPG_EXT}");
|
||||||
|
|
||||||
formState.CurrentMedia.HasAnnotations = mainWindow.Editor.CurrentDetections.Count != 0;
|
|
||||||
var annotations = await SaveAnnotationInner(imgPath, cancellationToken);
|
var annotations = await SaveAnnotationInner(imgPath, cancellationToken);
|
||||||
if (isVideo)
|
if (isVideo)
|
||||||
{
|
{
|
||||||
@@ -310,17 +309,19 @@ public class AnnotatorEventHandler(
|
|||||||
mainWindow.Editor.RemoveAllAnns();
|
mainWindow.Editor.RemoveAllAnns();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<Annotation>> SaveAnnotationInner(string imgPath, CancellationToken cancellationToken = default)
|
private async Task<List<Annotation>> SaveAnnotationInner(string imgPath, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
var canvasDetections = mainWindow.Editor.CurrentDetections.Select(x => x.ToCanvasLabel()).ToList();
|
var canvasDetections = mainWindow.Editor.CurrentDetections.Select(x => x.ToCanvasLabel()).ToList();
|
||||||
|
|
||||||
var source = (mainWindow.Editor.BackgroundImage.Source as BitmapSource)!;
|
var source = (mainWindow.Editor.BackgroundImage.Source as BitmapSource)!;
|
||||||
var mediaSize = new Size(source.PixelWidth, source.PixelHeight);
|
var mediaSize = new Size(source.PixelWidth, source.PixelHeight);
|
||||||
var annotationsResult = new List<Annotation>();
|
var annotationsResult = new List<Annotation>();
|
||||||
|
var time = formState.BackgroundTime ?? TimeSpan.FromMilliseconds(mediaPlayer.Time);
|
||||||
|
|
||||||
if (!File.Exists(imgPath))
|
if (!File.Exists(imgPath))
|
||||||
{
|
{
|
||||||
if (mediaSize.FitSizeForAI())
|
if (mediaSize.FitSizeForAI())
|
||||||
await source.SaveImage(imgPath, cancellationToken);
|
await source.SaveImage(imgPath, ct);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Tiling
|
//Tiling
|
||||||
@@ -331,17 +332,16 @@ public class AnnotatorEventHandler(
|
|||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
//2. Split to frames
|
//2. Split to frames
|
||||||
var results = TileProcessor.Split(formState.CurrentMediaSize, detectionCoords, cancellationToken);
|
var results = TileProcessor.Split(formState.CurrentMediaSize, detectionCoords, ct);
|
||||||
|
|
||||||
//3. Save each frame as a separate annotation
|
//3. Save each frame as a separate annotation
|
||||||
foreach (var res in results)
|
foreach (var res in results)
|
||||||
{
|
{
|
||||||
var time = TimeSpan.Zero;
|
var annotationName = $"{formState.CurrentMedia?.Name ?? ""}{Constants.SPLIT_SUFFIX}{res.Tile.Width}_{res.Tile.Left:0000}_{res.Tile.Top:0000}!".ToTimeName(time);
|
||||||
var annotationName = $"{formState.MediaName}{Constants.SPLIT_SUFFIX}{res.Tile.Width}_{res.Tile.Left:0000}_{res.Tile.Top:0000}!".ToTimeName(time);
|
|
||||||
|
|
||||||
var tileImgPath = Path.Combine(dirConfig.Value.ImagesDirectory, $"{annotationName}{Constants.JPG_EXT}");
|
var tileImgPath = Path.Combine(dirConfig.Value.ImagesDirectory, $"{annotationName}{Constants.JPG_EXT}");
|
||||||
var bitmap = new CroppedBitmap(source, new Int32Rect((int)res.Tile.Left, (int)res.Tile.Top, (int)res.Tile.Width, (int)res.Tile.Height));
|
var bitmap = new CroppedBitmap(source, new Int32Rect((int)res.Tile.Left, (int)res.Tile.Top, (int)res.Tile.Width, (int)res.Tile.Height));
|
||||||
await bitmap.SaveImage(tileImgPath, cancellationToken);
|
await bitmap.SaveImage(tileImgPath, ct);
|
||||||
|
|
||||||
var frameSize = new Size(res.Tile.Width, res.Tile.Height);
|
var frameSize = new Size(res.Tile.Width, res.Tile.Height);
|
||||||
var detections = res.Detections
|
var detections = res.Detections
|
||||||
@@ -349,18 +349,17 @@ public class AnnotatorEventHandler(
|
|||||||
.Select(x => new Detection(annotationName, new YoloLabel(x, frameSize)))
|
.Select(x => new Detection(annotationName, new YoloLabel(x, frameSize)))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
annotationsResult.Add(await annotationService.SaveAnnotation(formState.MediaName, annotationName, time, detections, token: cancellationToken));
|
annotationsResult.Add(await annotationService.SaveAnnotation(formState.CurrentMediaHash, formState.CurrentMediaName, annotationName, time, detections, token: ct));
|
||||||
}
|
}
|
||||||
return annotationsResult;
|
return annotationsResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var timeImg = formState.BackgroundTime ?? TimeSpan.FromMilliseconds(mediaPlayer.Time);
|
var annName = (formState.CurrentMedia?.Name ?? "").ToTimeName(time);
|
||||||
var annName = formState.MediaName.ToTimeName(timeImg);
|
|
||||||
var currentDetections = canvasDetections.Select(x =>
|
var currentDetections = canvasDetections.Select(x =>
|
||||||
new Detection(annName, new YoloLabel(x, mainWindow.Editor.RenderSize, mediaSize)))
|
new Detection(annName, new YoloLabel(x, mainWindow.Editor.RenderSize, mediaSize)))
|
||||||
.ToList();
|
.ToList();
|
||||||
var annotation = await annotationService.SaveAnnotation(formState.MediaName, annName, timeImg, currentDetections, token: cancellationToken);
|
var annotation = await annotationService.SaveAnnotation(formState.CurrentMediaHash, formState.CurrentMediaName, annName, time, currentDetections, token: ct);
|
||||||
return [annotation];
|
return [annotation];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,15 +382,7 @@ public class AnnotatorEventHandler(
|
|||||||
.Select(x => x.Value).ToList();
|
.Select(x => x.Value).ToList();
|
||||||
mainWindow.TimedAnnotations.Remove(timedAnnotationsToRemove);
|
mainWindow.TimedAnnotations.Remove(timedAnnotationsToRemove);
|
||||||
|
|
||||||
if (formState.AnnotationResults.Count == 0)
|
mainWindow.ReloadFilesThrottled();
|
||||||
{
|
|
||||||
var media = mainWindow.AllMediaFiles.FirstOrDefault(x => x.Name == formState.CurrentMedia?.Name);
|
|
||||||
if (media != null)
|
|
||||||
{
|
|
||||||
media.HasAnnotations = false;
|
|
||||||
mainWindow.LvFiles.Items.Refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await dbFactory.DeleteAnnotations(notification.AnnotationNames, ct);
|
await dbFactory.DeleteAnnotations(notification.AnnotationNames, ct);
|
||||||
@@ -412,7 +403,8 @@ public class AnnotatorEventHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Only validators can send Delete to the queue
|
//Only validators can send Delete to the queue
|
||||||
if (!notification.FromQueue && api.CurrentUser.Role.IsValidator())
|
var currentUser = await api.GetCurrentUserAsync();
|
||||||
|
if (!notification.FromQueue && currentUser.Role.IsValidator())
|
||||||
await producer.SendToInnerQueue(notification.AnnotationNames, AnnotationStatus.Deleted, ct);
|
await producer.SendToInnerQueue(notification.AnnotationNames, AnnotationStatus.Deleted, ct);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -426,9 +418,8 @@ public class AnnotatorEventHandler(
|
|||||||
{
|
{
|
||||||
mainWindow.Dispatcher.Invoke(() =>
|
mainWindow.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
|
var mediaInfo = (MediaFile)mainWindow.LvFiles.SelectedItem;
|
||||||
var mediaInfo = (MediaFileInfo)mainWindow.LvFiles.SelectedItem;
|
if ((mediaInfo?.Name ?? "") == e.Annotation.OriginalMediaName)
|
||||||
if ((mediaInfo?.FName ?? "") == e.Annotation.OriginalMediaName)
|
|
||||||
mainWindow.AddAnnotation(e.Annotation);
|
mainWindow.AddAnnotation(e.Annotation);
|
||||||
|
|
||||||
var log = string.Join(Environment.NewLine, e.Annotation.Detections.Select(det =>
|
var log = string.Join(Environment.NewLine, e.Annotation.Detections.Select(det =>
|
||||||
@@ -441,7 +432,7 @@ public class AnnotatorEventHandler(
|
|||||||
|
|
||||||
var media = mainWindow.MediaFilesDict.GetValueOrDefault(e.Annotation.OriginalMediaName);
|
var media = mainWindow.MediaFilesDict.GetValueOrDefault(e.Annotation.OriginalMediaName);
|
||||||
if (media != null)
|
if (media != null)
|
||||||
media.HasAnnotations = true;
|
mainWindow.ReloadFilesThrottled();
|
||||||
|
|
||||||
mainWindow.LvFiles.Items.Refresh();
|
mainWindow.LvFiles.Items.Refresh();
|
||||||
mainWindow.StatusHelp.Text = log;
|
mainWindow.StatusHelp.Text = log;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using Azaion.Common;
|
||||||
using Azaion.Common.Database;
|
using Azaion.Common.Database;
|
||||||
using Azaion.Common.DTO;
|
using Azaion.Common.DTO;
|
||||||
using Azaion.Common.DTO.Config;
|
using Azaion.Common.DTO.Config;
|
||||||
@@ -18,7 +19,7 @@ namespace Azaion.Annotator.Controls;
|
|||||||
public partial class MapMatcher : UserControl
|
public partial class MapMatcher : UserControl
|
||||||
{
|
{
|
||||||
private AppConfig _appConfig = null!;
|
private AppConfig _appConfig = null!;
|
||||||
List<MediaFileInfo> _allMediaFiles = new();
|
List<MediaFile> _allMediaFiles = new();
|
||||||
public Dictionary<int, Annotation> Annotations = new();
|
public Dictionary<int, Annotation> Annotations = new();
|
||||||
private string _currentDir = null!;
|
private string _currentDir = null!;
|
||||||
private IGpsMatcherService _gpsMatcherService = null!;
|
private IGpsMatcherService _gpsMatcherService = null!;
|
||||||
@@ -63,11 +64,11 @@ public partial class MapMatcher : UserControl
|
|||||||
|
|
||||||
private void OpenContainingFolder(object sender, RoutedEventArgs e)
|
private void OpenContainingFolder(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var mediaFileInfo = (sender as MenuItem)?.DataContext as MediaFileInfo;
|
var mediaFileInfo = (sender as MenuItem)?.DataContext as MediaFile;
|
||||||
if (mediaFileInfo == null)
|
if (mediaFileInfo == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Process.Start("explorer.exe", "/select,\"" + mediaFileInfo.Path +"\"");
|
Process.Start("explorer.exe", "/select,\"" + mediaFileInfo.MediaUrl +"\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OpenGpsTilesFolderClick(object sender, RoutedEventArgs e)
|
private async void OpenGpsTilesFolderClick(object sender, RoutedEventArgs e)
|
||||||
@@ -86,16 +87,16 @@ public partial class MapMatcher : UserControl
|
|||||||
TbGpsMapFolder.Text = dlg.FileName;
|
TbGpsMapFolder.Text = dlg.FileName;
|
||||||
_currentDir = dlg.FileName;
|
_currentDir = dlg.FileName;
|
||||||
var dir = new DirectoryInfo(dlg.FileName);
|
var dir = new DirectoryInfo(dlg.FileName);
|
||||||
var mediaFiles = dir.GetFiles(_appConfig.AnnotationConfig.ImageFormats.ToArray())
|
var mediaFiles = dir.GetFiles(Constants.DefaultImageFormats.ToArray())
|
||||||
.Select(x => new MediaFileInfo
|
.Select(x => new MediaFile
|
||||||
{
|
{
|
||||||
Name = x.Name,
|
Name = x.Name,
|
||||||
Path = x.FullName,
|
MediaUrl = x.FullName,
|
||||||
MediaType = MediaTypes.Image
|
MediaType = MediaTypes.Image
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
_allMediaFiles = mediaFiles;
|
_allMediaFiles = mediaFiles;
|
||||||
GpsFiles.ItemsSource = new ObservableCollection<MediaFileInfo>(_allMediaFiles);
|
GpsFiles.ItemsSource = new ObservableCollection<MediaFile>(_allMediaFiles);
|
||||||
|
|
||||||
Annotations = mediaFiles.Select((x, i) => (i, new Annotation
|
Annotations = mediaFiles.Select((x, i) => (i, new Annotation
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
<PackageReference Include="Stub.System.Data.SQLite.Core.NetStandard" Version="1.0.119" />
|
<PackageReference Include="Stub.System.Data.SQLite.Core.NetStandard" Version="1.0.119" />
|
||||||
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.119" />
|
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.119" />
|
||||||
<PackageReference Include="System.Drawing.Common" Version="5.0.3" />
|
<PackageReference Include="System.Drawing.Common" Version="5.0.3" />
|
||||||
|
<PackageReference Include="System.IO.Hashing" Version="9.0.9" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -98,14 +98,12 @@ public static class Constants
|
|||||||
new() { Id = 18, Name = "Protect.Struct", ShortName = "Зуби.драк", Color = "#969647".ToColor(), MaxSizeM = 2 }
|
new() { Id = 18, Name = "Protect.Struct", ShortName = "Зуби.драк", Color = "#969647".ToColor(), MaxSizeM = 2 }
|
||||||
];
|
];
|
||||||
|
|
||||||
public static readonly List<string> DefaultVideoFormats = ["mp4", "mov", "avi", "ts"];
|
public static readonly List<string> DefaultVideoFormats = [".mp4", ".mov", ".avi", ".ts", ".mkv"];
|
||||||
public static readonly List<string> DefaultImageFormats = ["jpg", "jpeg", "png", "bmp"];
|
public static readonly List<string> DefaultImageFormats = [".jpg", ".jpeg", ".png", ".bmp"];
|
||||||
|
|
||||||
private static readonly AnnotationConfig DefaultAnnotationConfig = new()
|
private static readonly AnnotationConfig DefaultAnnotationConfig = new()
|
||||||
{
|
{
|
||||||
DetectionClasses = DefaultAnnotationClasses,
|
DetectionClasses = DefaultAnnotationClasses,
|
||||||
VideoFormats = DefaultVideoFormats,
|
|
||||||
ImageFormats = DefaultImageFormats,
|
|
||||||
AnnotationsDbFile = DEFAULT_ANNOTATIONS_DB_FILE
|
AnnotationsDbFile = DEFAULT_ANNOTATIONS_DB_FILE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ using System.Windows.Shapes;
|
|||||||
using Azaion.Common.Database;
|
using Azaion.Common.Database;
|
||||||
using Azaion.Common.DTO;
|
using Azaion.Common.DTO;
|
||||||
using Azaion.Common.Extensions;
|
using Azaion.Common.Extensions;
|
||||||
using MediatR;
|
|
||||||
using Color = System.Windows.Media.Color;
|
using Color = System.Windows.Media.Color;
|
||||||
using Image = System.Windows.Controls.Image;
|
using Image = System.Windows.Controls.Image;
|
||||||
using Point = System.Windows.Point;
|
using Point = System.Windows.Point;
|
||||||
@@ -20,7 +19,7 @@ namespace Azaion.Common.Controls;
|
|||||||
public class CanvasEditor : Canvas
|
public class CanvasEditor : Canvas
|
||||||
{
|
{
|
||||||
private Point _lastPos;
|
private Point _lastPos;
|
||||||
public SelectionState SelectionState { get; set; } = SelectionState.None;
|
private SelectionState SelectionState { get; set; } = SelectionState.None;
|
||||||
|
|
||||||
private readonly Rectangle _newAnnotationRect;
|
private readonly Rectangle _newAnnotationRect;
|
||||||
private Point _newAnnotationStartPos;
|
private Point _newAnnotationStartPos;
|
||||||
@@ -30,7 +29,7 @@ public class CanvasEditor : Canvas
|
|||||||
private readonly TextBlock _classNameHint;
|
private readonly TextBlock _classNameHint;
|
||||||
|
|
||||||
private Rectangle _curRec = new();
|
private Rectangle _curRec = new();
|
||||||
private DetectionControl _curAnn = null!;
|
private DetectionControl? _curAnn;
|
||||||
|
|
||||||
private readonly MatrixTransform _matrixTransform = new();
|
private readonly MatrixTransform _matrixTransform = new();
|
||||||
private Point _panStartPoint;
|
private Point _panStartPoint;
|
||||||
@@ -56,12 +55,12 @@ public class CanvasEditor : Canvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DetectionClass _currentAnnClass = null!;
|
private DetectionClass _currentAnnClass = null!;
|
||||||
public DetectionClass CurrentAnnClass
|
public DetectionClass? CurrentAnnClass
|
||||||
{
|
{
|
||||||
get => _currentAnnClass;
|
get => _currentAnnClass;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_verticalLine.Stroke = value.ColorBrush;
|
_verticalLine.Stroke = value!.ColorBrush;
|
||||||
_verticalLine.Fill = value.ColorBrush;
|
_verticalLine.Fill = value.ColorBrush;
|
||||||
_horizontalLine.Stroke = value.ColorBrush;
|
_horizontalLine.Stroke = value.ColorBrush;
|
||||||
_horizontalLine.Fill = value.ColorBrush;
|
_horizontalLine.Fill = value.ColorBrush;
|
||||||
@@ -251,7 +250,7 @@ public class CanvasEditor : Canvas
|
|||||||
if (width >= MIN_SIZE && height >= MIN_SIZE)
|
if (width >= MIN_SIZE && height >= MIN_SIZE)
|
||||||
{
|
{
|
||||||
var time = GetTimeFunc();
|
var time = GetTimeFunc();
|
||||||
var control = CreateDetectionControl(CurrentAnnClass, time, new CanvasLabel
|
var control = CreateDetectionControl(CurrentAnnClass!, time, new CanvasLabel
|
||||||
{
|
{
|
||||||
Width = width,
|
Width = width,
|
||||||
Height = height,
|
Height = height,
|
||||||
@@ -263,7 +262,7 @@ public class CanvasEditor : Canvas
|
|||||||
CheckLabelBoundaries(control);
|
CheckLabelBoundaries(control);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (SelectionState != SelectionState.PanZoomMoving)
|
else if (SelectionState != SelectionState.PanZoomMoving && _curAnn != null)
|
||||||
CheckLabelBoundaries(_curAnn);
|
CheckLabelBoundaries(_curAnn);
|
||||||
|
|
||||||
SelectionState = SelectionState.None;
|
SelectionState = SelectionState.None;
|
||||||
@@ -353,7 +352,7 @@ public class CanvasEditor : Canvas
|
|||||||
|
|
||||||
private void AnnotationResizeMove(Point point)
|
private void AnnotationResizeMove(Point point)
|
||||||
{
|
{
|
||||||
if (SelectionState != SelectionState.AnnResizing)
|
if (SelectionState != SelectionState.AnnResizing || _curAnn == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var x = GetLeft(_curAnn);
|
var x = GetLeft(_curAnn);
|
||||||
@@ -418,7 +417,7 @@ public class CanvasEditor : Canvas
|
|||||||
|
|
||||||
private void AnnotationPositionMove(Point point)
|
private void AnnotationPositionMove(Point point)
|
||||||
{
|
{
|
||||||
if (SelectionState != SelectionState.AnnMoving)
|
if (SelectionState != SelectionState.AnnMoving || _curAnn == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var offsetX = point.X - _lastPos.X;
|
var offsetX = point.X - _lastPos.X;
|
||||||
@@ -442,14 +441,14 @@ public class CanvasEditor : Canvas
|
|||||||
|
|
||||||
#region NewAnnotation
|
#region NewAnnotation
|
||||||
|
|
||||||
private void NewAnnotationStart(object sender, MouseButtonEventArgs e)
|
private void NewAnnotationStart(object _, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
_newAnnotationStartPos = e.GetPosition(this);
|
_newAnnotationStartPos = e.GetPosition(this);
|
||||||
SetLeft(_newAnnotationRect, _newAnnotationStartPos.X);
|
SetLeft(_newAnnotationRect, _newAnnotationStartPos.X);
|
||||||
SetTop(_newAnnotationRect, _newAnnotationStartPos.Y);
|
SetTop(_newAnnotationRect, _newAnnotationStartPos.Y);
|
||||||
_newAnnotationRect.MouseMove += (sender, e) =>
|
_newAnnotationRect.MouseMove += (_, args) =>
|
||||||
{
|
{
|
||||||
var currentPos = e.GetPosition(this);
|
var currentPos = args.GetPosition(this);
|
||||||
NewAnnotationCreatingMove(currentPos);
|
NewAnnotationCreatingMove(currentPos);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,5 @@ public class AnnotationConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> VideoFormats { get; set; } = null!;
|
|
||||||
public List<string> ImageFormats { get; set; } = null!;
|
|
||||||
|
|
||||||
public string AnnotationsDbFile { get; set; } = null!;
|
public string AnnotationsDbFile { get; set; } = null!;
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,9 @@ namespace Azaion.Common.DTO;
|
|||||||
|
|
||||||
public class FormState
|
public class FormState
|
||||||
{
|
{
|
||||||
public MediaFileInfo? CurrentMedia { get; set; }
|
public MediaFile? CurrentMedia { get; set; }
|
||||||
public string MediaName => CurrentMedia?.FName ?? "";
|
public string CurrentMediaHash => CurrentMedia?.Hash ?? "";
|
||||||
|
public string CurrentMediaName => CurrentMedia?.Name ?? "";
|
||||||
|
|
||||||
public Size CurrentMediaSize { get; set; }
|
public Size CurrentMediaSize { get; set; }
|
||||||
public TimeSpan CurrentVideoLength { get; set; }
|
public TimeSpan CurrentVideoLength { get; set; }
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
using Azaion.Common.Extensions;
|
|
||||||
|
|
||||||
namespace Azaion.Common.DTO;
|
|
||||||
|
|
||||||
public class MediaFileInfo
|
|
||||||
{
|
|
||||||
public string Name { get; set; } = null!;
|
|
||||||
public string Path { get; set; } = null!;
|
|
||||||
public TimeSpan Duration { get; set; }
|
|
||||||
public string DurationStr => $"{Duration:h\\:mm\\:ss}";
|
|
||||||
public bool HasAnnotations { get; set; }
|
|
||||||
public MediaTypes MediaType { get; set; }
|
|
||||||
|
|
||||||
public string FName => Name.ToFName();
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace Azaion.Common.DTO;
|
|
||||||
|
|
||||||
public enum MediaTypes
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Video = 1,
|
|
||||||
Image = 2
|
|
||||||
}
|
|
||||||
@@ -8,6 +8,7 @@ public class AnnotationMessage
|
|||||||
{
|
{
|
||||||
[Key(0)] public DateTime CreatedDate { get; set; }
|
[Key(0)] public DateTime CreatedDate { get; set; }
|
||||||
[Key(1)] public string Name { get; set; } = null!;
|
[Key(1)] public string Name { get; set; } = null!;
|
||||||
|
[Key(11)] public string MediaHash { get; set; } = null!;
|
||||||
[Key(2)] public string OriginalMediaName { get; set; } = null!;
|
[Key(2)] public string OriginalMediaName { get; set; } = null!;
|
||||||
[Key(3)] public TimeSpan Time { get; set; }
|
[Key(3)] public TimeSpan Time { get; set; }
|
||||||
[Key(4)] public string ImageExtension { get; set; } = null!;
|
[Key(4)] public string ImageExtension { get; set; } = null!;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public class Annotation
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Key("n")] public string Name { get; set; } = null!;
|
[Key("n")] public string Name { get; set; } = null!;
|
||||||
|
[Key("hash")] public string MediaHash { get; set; } = null!;
|
||||||
[Key("mn")] public string OriginalMediaName { get; set; } = null!;
|
[Key("mn")] public string OriginalMediaName { get; set; } = null!;
|
||||||
[IgnoreMember] public TimeSpan Time { get; set; }
|
[IgnoreMember] public TimeSpan Time { get; set; }
|
||||||
[IgnoreMember] public string ImageExtension { get; set; } = null!;
|
[IgnoreMember] public string ImageExtension { get; set; } = null!;
|
||||||
@@ -93,13 +94,9 @@ public class Annotation
|
|||||||
return _className;
|
return _className;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion Calculated
|
#endregion Calculated
|
||||||
|
|
||||||
|
public override string ToString() => $"Annotation: {Name}{TimeStr}: {ClassName}";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[MessagePackObject]
|
[MessagePackObject]
|
||||||
|
|||||||
@@ -17,15 +17,21 @@ public static class AnnotationsDbSchemaHolder
|
|||||||
annotationBuilder.HasTableName(Constants.ANNOTATIONS_TABLENAME)
|
annotationBuilder.HasTableName(Constants.ANNOTATIONS_TABLENAME)
|
||||||
.HasPrimaryKey(x => x.Name)
|
.HasPrimaryKey(x => x.Name)
|
||||||
.Association(a => a.Detections, (a, d) => a.Name == d.AnnotationName)
|
.Association(a => a.Detections, (a, d) => a.Name == d.AnnotationName)
|
||||||
.Property(x => x.Time).HasDataType(DataType.Int64).HasConversion(ts => ts.Ticks, t => new TimeSpan(t));
|
.Property(x => x.Time)
|
||||||
|
.HasDataType(DataType.Int64)
|
||||||
|
.HasConversion(ts => ts.Ticks, t => new TimeSpan(t));
|
||||||
|
|
||||||
annotationBuilder
|
annotationBuilder
|
||||||
.Ignore(x => x.Milliseconds)
|
.Ignore(x => x.Milliseconds)
|
||||||
.Ignore(x => x.Classes)
|
.Ignore(x => x.Classes)
|
||||||
.Ignore(x => x.Classes)
|
|
||||||
.Ignore(x => x.ImagePath)
|
.Ignore(x => x.ImagePath)
|
||||||
.Ignore(x => x.LabelPath)
|
.Ignore(x => x.LabelPath)
|
||||||
.Ignore(x => x.ThumbPath);
|
.Ignore(x => x.ThumbPath)
|
||||||
|
.Ignore(x => x.ClassName)
|
||||||
|
.Ignore(x => x.Colors)
|
||||||
|
.Ignore(x => x.SplitTile)
|
||||||
|
.Ignore(x => x.IsSplit)
|
||||||
|
.Ignore(x => x.TimeStr);
|
||||||
|
|
||||||
builder.Entity<Detection>()
|
builder.Entity<Detection>()
|
||||||
.HasTableName(Constants.DETECTIONS_TABLENAME);
|
.HasTableName(Constants.DETECTIONS_TABLENAME);
|
||||||
@@ -38,7 +44,11 @@ public static class AnnotationsDbSchemaHolder
|
|||||||
.HasConversion(list => JsonConvert.SerializeObject(list), str => JsonConvert.DeserializeObject<List<string>>(str) ?? new List<string>());
|
.HasConversion(list => JsonConvert.SerializeObject(list), str => JsonConvert.DeserializeObject<List<string>>(str) ?? new List<string>());
|
||||||
|
|
||||||
builder.Entity<MediaFile>()
|
builder.Entity<MediaFile>()
|
||||||
.HasTableName(Constants.MEDIAFILE_TABLENAME);
|
.HasTableName(Constants.MEDIAFILE_TABLENAME)
|
||||||
|
.HasPrimaryKey(x => x.Hash)
|
||||||
|
.Association(a => a.Annotations, (mf, a) =>
|
||||||
|
mf.Name == a.OriginalMediaName ||
|
||||||
|
mf.Hash == a.MediaHash);
|
||||||
|
|
||||||
builder.Build();
|
builder.Build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ public class DbFactory : IDbFactory
|
|||||||
.UseMappingSchema(AnnotationsDbSchemaHolder.MappingSchema)
|
.UseMappingSchema(AnnotationsDbSchemaHolder.MappingSchema)
|
||||||
.UseTracing(TraceLevel.Info, t => logger.LogInformation(t.SqlText));
|
.UseTracing(TraceLevel.Info, t => logger.LogInformation(t.SqlText));
|
||||||
|
|
||||||
|
|
||||||
_fileConnection = new SQLiteConnection(FileConnStr);
|
_fileConnection = new SQLiteConnection(FileConnStr);
|
||||||
_fileDataOptions = new DataOptions()
|
_fileDataOptions = new DataOptions()
|
||||||
.UseDataProvider(SQLiteTools.GetDataProvider())
|
.UseDataProvider(SQLiteTools.GetDataProvider())
|
||||||
|
|||||||
@@ -1,12 +1,43 @@
|
|||||||
|
using System.IO;
|
||||||
|
using Azaion.Common.Extensions;
|
||||||
|
using Azaion.Common.Services;
|
||||||
|
|
||||||
namespace Azaion.Common.Database;
|
namespace Azaion.Common.Database;
|
||||||
|
|
||||||
public class MediaFile
|
public class MediaFile
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = null!;
|
public string Hash { get; set; } = null!;
|
||||||
public string MediaUrl { get; set; } = null!;
|
public string MediaUrl { get; set; } = null!;
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
public DateTime? LastProcessedDate { get; set; }
|
public DateTime? LastProcessedDate { get; set; }
|
||||||
public MediaStatus Status { get; set; } = MediaStatus.New;
|
public MediaTypes MediaType { get; set; } = MediaTypes.None;
|
||||||
public int? RecognisedObjects { get; set; }
|
public MediaStatus Status { get; set; } = MediaStatus.None;
|
||||||
|
public IEnumerable<Annotation> Annotations { get; set; } = null!;
|
||||||
|
|
||||||
|
public MediaFile() { }
|
||||||
|
|
||||||
|
public MediaFile(string path)
|
||||||
|
{
|
||||||
|
var fileInfo = new FileInfo(path);
|
||||||
|
var mediaType = Constants.DefaultVideoFormats.Contains(fileInfo.Extension, StringComparer.OrdinalIgnoreCase)
|
||||||
|
? MediaTypes.Video
|
||||||
|
: Constants.DefaultImageFormats.Contains(fileInfo.Extension, StringComparer.OrdinalIgnoreCase)
|
||||||
|
? MediaTypes.Image
|
||||||
|
: MediaTypes.None;
|
||||||
|
Hash = fileInfo.CalcHash();
|
||||||
|
MediaUrl = path;
|
||||||
|
Name = path.ToFName();
|
||||||
|
MediaType = mediaType;
|
||||||
|
Status = MediaStatus.New;
|
||||||
|
LastProcessedDate = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MediaTypes
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Video = 1,
|
||||||
|
Image = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MediaStatus
|
public enum MediaStatus
|
||||||
@@ -15,6 +46,7 @@ public enum MediaStatus
|
|||||||
New,
|
New,
|
||||||
AIProcessing,
|
AIProcessing,
|
||||||
AIProcessed,
|
AIProcessed,
|
||||||
ManualConfirmed,
|
ManualCreated,
|
||||||
|
Confirmed,
|
||||||
Error
|
Error
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,8 @@ public class AnnotationService : IAnnotationService
|
|||||||
|
|
||||||
private async Task InitQueueConsumer(CancellationToken token = default)
|
private async Task InitQueueConsumer(CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!_api.CurrentUser.Role.IsValidator())
|
var currentUser = await _api.GetCurrentUserAsync();
|
||||||
|
if (!currentUser.Role.IsValidator())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var consumerSystem = await StreamSystem.Create(new StreamSystemConfig
|
var consumerSystem = await StreamSystem.Create(new StreamSystemConfig
|
||||||
@@ -72,11 +73,11 @@ public class AnnotationService : IAnnotationService
|
|||||||
Password = _queueConfig.ConsumerPassword
|
Password = _queueConfig.ConsumerPassword
|
||||||
});
|
});
|
||||||
|
|
||||||
var offsets = _api.CurrentUser.UserConfig?.QueueOffsets ?? new UserQueueOffsets();
|
var offsets = currentUser.UserConfig?.QueueOffsets ?? new UserQueueOffsets();
|
||||||
|
|
||||||
_consumer = await Consumer.Create(new ConsumerConfig(consumerSystem, Constants.MQ_ANNOTATIONS_QUEUE)
|
_consumer = await Consumer.Create(new ConsumerConfig(consumerSystem, Constants.MQ_ANNOTATIONS_QUEUE)
|
||||||
{
|
{
|
||||||
Reference = _api.CurrentUser.Email,
|
Reference = currentUser.Email,
|
||||||
OffsetSpec = new OffsetTypeOffset(offsets.AnnotationsOffset),
|
OffsetSpec = new OffsetTypeOffset(offsets.AnnotationsOffset),
|
||||||
MessageHandler = async (_, _, context, message) =>
|
MessageHandler = async (_, _, context, message) =>
|
||||||
{
|
{
|
||||||
@@ -87,13 +88,14 @@ public class AnnotationService : IAnnotationService
|
|||||||
if (!Enum.TryParse<AnnotationStatus>((string)message.ApplicationProperties[nameof(AnnotationStatus)], out var annotationStatus))
|
if (!Enum.TryParse<AnnotationStatus>((string)message.ApplicationProperties[nameof(AnnotationStatus)], out var annotationStatus))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (email != _api.CurrentUser.Email) //Don't process messages by yourself
|
if (email != currentUser.Email)
|
||||||
{
|
{
|
||||||
if (annotationStatus.In(AnnotationStatus.Created, AnnotationStatus.Edited))
|
if (annotationStatus.In(AnnotationStatus.Created, AnnotationStatus.Edited))
|
||||||
{
|
{
|
||||||
var msg = MessagePackSerializer.Deserialize<AnnotationMessage>(message.Data.Contents);
|
var msg = MessagePackSerializer.Deserialize<AnnotationMessage>(message.Data.Contents);
|
||||||
await SaveAnnotationInner(
|
await SaveAnnotationInner(
|
||||||
msg.CreatedDate,
|
msg.CreatedDate,
|
||||||
|
msg.MediaHash,
|
||||||
msg.OriginalMediaName,
|
msg.OriginalMediaName,
|
||||||
msg.Name,
|
msg.Name,
|
||||||
msg.Time,
|
msg.Time,
|
||||||
@@ -115,12 +117,9 @@ public class AnnotationService : IAnnotationService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
offsets.AnnotationsOffset = context.Offset + 1; //to consume on the next launch from the next message
|
offsets.AnnotationsOffset = context.Offset + 1;
|
||||||
ThrottleExt.Throttle(() =>
|
ThrottleExt.Throttle(async () => await _api.UpdateOffsetsAsync(offsets),
|
||||||
{
|
SaveQueueOffsetTaskId, TimeSpan.FromSeconds(10), scheduleCallAfterCooldown: true);
|
||||||
_api.UpdateOffsets(offsets);
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}, SaveQueueOffsetTaskId, TimeSpan.FromSeconds(10), scheduleCallAfterCooldown: true);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -137,17 +136,21 @@ public class AnnotationService : IAnnotationService
|
|||||||
//AI
|
//AI
|
||||||
public async Task<Annotation> SaveAnnotation(AnnotationImage a, CancellationToken ct = default)
|
public async Task<Annotation> SaveAnnotation(AnnotationImage a, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
|
var currentUser = await _api.GetCurrentUserAsync();
|
||||||
a.Time = TimeSpan.FromMilliseconds(a.Milliseconds);
|
a.Time = TimeSpan.FromMilliseconds(a.Milliseconds);
|
||||||
return await SaveAnnotationInner(DateTime.UtcNow, a.OriginalMediaName, a.Name, a.Time, a.Detections.ToList(),
|
return await SaveAnnotationInner(DateTime.UtcNow, a.MediaHash, a.OriginalMediaName, a.Name, a.Time, a.Detections.ToList(),
|
||||||
SourceEnum.AI, new MemoryStream(a.Image), _api.CurrentUser.Role, _api.CurrentUser.Email, token: ct);
|
SourceEnum.AI, new MemoryStream(a.Image), currentUser.Role, currentUser.Email, token: ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Manual
|
//Manual
|
||||||
public async Task<Annotation> SaveAnnotation(string originalMediaName, string annotationName, TimeSpan time, List<Detection> detections, Stream? stream = null, CancellationToken token = default) =>
|
public async Task<Annotation> SaveAnnotation(string mediaHash, string originalMediaName, string annotationName, TimeSpan time, List<Detection> detections,
|
||||||
await SaveAnnotationInner(DateTime.UtcNow, originalMediaName, annotationName, time, detections, SourceEnum.Manual, stream,
|
Stream? stream = null, CancellationToken token = default)
|
||||||
_api.CurrentUser.Role, _api.CurrentUser.Email, token: token);
|
{
|
||||||
|
var currentUser = await _api.GetCurrentUserAsync();
|
||||||
|
return await SaveAnnotationInner(DateTime.UtcNow, mediaHash, originalMediaName, annotationName, time, detections, SourceEnum.Manual, stream, currentUser.Role, currentUser.Email, token: token);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<Annotation> SaveAnnotationInner(DateTime createdDate, string originalMediaName, string annotationName, TimeSpan time,
|
private async Task<Annotation> SaveAnnotationInner(DateTime createdDate, string mediaHash, string originalMediaName, string annotationName, TimeSpan time,
|
||||||
List<Detection> detections, SourceEnum source, Stream? stream,
|
List<Detection> detections, SourceEnum source, Stream? stream,
|
||||||
RoleEnum userRole,
|
RoleEnum userRole,
|
||||||
string createdEmail,
|
string createdEmail,
|
||||||
@@ -163,13 +166,17 @@ public class AnnotationService : IAnnotationService
|
|||||||
|
|
||||||
await db.Detections.DeleteAsync(x => x.AnnotationName == annotationName, token: token);
|
await db.Detections.DeleteAsync(x => x.AnnotationName == annotationName, token: token);
|
||||||
|
|
||||||
if (ann != null) //Annotation is already exists
|
if (ann != null)
|
||||||
{
|
{
|
||||||
status = AnnotationStatus.Edited;
|
status = AnnotationStatus.Edited;
|
||||||
|
|
||||||
var annotationUpdatable = db.Annotations
|
var annotationUpdatable = db.Annotations
|
||||||
.Where(x => x.Name == annotationName)
|
.Where(x => x.Name == annotationName)
|
||||||
.Set(x => x.Source, source);
|
.Set(x => x.Source, source)
|
||||||
|
.Set(x => x.OriginalMediaName, originalMediaName);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(mediaHash))
|
||||||
|
annotationUpdatable = annotationUpdatable.Set(x => x.MediaHash, mediaHash);
|
||||||
|
|
||||||
if (userRole.IsValidator() && source == SourceEnum.Manual)
|
if (userRole.IsValidator() && source == SourceEnum.Manual)
|
||||||
{
|
{
|
||||||
@@ -183,6 +190,7 @@ public class AnnotationService : IAnnotationService
|
|||||||
.UpdateAsync(token: token);
|
.UpdateAsync(token: token);
|
||||||
|
|
||||||
ann.Detections = detections;
|
ann.Detections = detections;
|
||||||
|
ann.MediaHash = mediaHash;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -190,6 +198,7 @@ public class AnnotationService : IAnnotationService
|
|||||||
{
|
{
|
||||||
CreatedDate = createdDate,
|
CreatedDate = createdDate,
|
||||||
Name = annotationName,
|
Name = annotationName,
|
||||||
|
MediaHash = mediaHash,
|
||||||
OriginalMediaName = originalMediaName,
|
OriginalMediaName = originalMediaName,
|
||||||
Time = time,
|
Time = time,
|
||||||
ImageExtension = Constants.JPG_EXT,
|
ImageExtension = Constants.JPG_EXT,
|
||||||
@@ -244,7 +253,8 @@ public class AnnotationService : IAnnotationService
|
|||||||
|
|
||||||
public async Task ValidateAnnotations(List<string> annotationNames, bool fromQueue = false, CancellationToken token = default)
|
public async Task ValidateAnnotations(List<string> annotationNames, bool fromQueue = false, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!_api.CurrentUser.Role.IsValidator())
|
var currentUser = await _api.GetCurrentUserAsync();
|
||||||
|
if (!currentUser.Role.IsValidator())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var annNames = annotationNames.ToHashSet();
|
var annNames = annotationNames.ToHashSet();
|
||||||
@@ -254,7 +264,7 @@ public class AnnotationService : IAnnotationService
|
|||||||
.Where(x => annNames.Contains(x.Name))
|
.Where(x => annNames.Contains(x.Name))
|
||||||
.Set(x => x.AnnotationStatus, AnnotationStatus.Validated)
|
.Set(x => x.AnnotationStatus, AnnotationStatus.Validated)
|
||||||
.Set(x => x.ValidateDate, DateTime.UtcNow)
|
.Set(x => x.ValidateDate, DateTime.UtcNow)
|
||||||
.Set(x => x.ValidateEmail, _api.CurrentUser.Email)
|
.Set(x => x.ValidateEmail, currentUser.Email)
|
||||||
.UpdateAsync(token: token);
|
.UpdateAsync(token: token);
|
||||||
});
|
});
|
||||||
if (!fromQueue)
|
if (!fromQueue)
|
||||||
@@ -265,6 +275,6 @@ public class AnnotationService : IAnnotationService
|
|||||||
public interface IAnnotationService
|
public interface IAnnotationService
|
||||||
{
|
{
|
||||||
Task<Annotation> SaveAnnotation(AnnotationImage a, CancellationToken ct = default);
|
Task<Annotation> SaveAnnotation(AnnotationImage a, CancellationToken ct = default);
|
||||||
Task<Annotation> SaveAnnotation(string originalMediaName, string annotationName, TimeSpan time, List<Detection> detections, Stream? stream = null, CancellationToken token = default);
|
Task<Annotation> SaveAnnotation(string mediaHash, string originalMediaName, string annotationName, TimeSpan time, List<Detection> detections, Stream? stream = null, CancellationToken token = default);
|
||||||
Task ValidateAnnotations(List<string> annotationNames, bool fromQueue = false, CancellationToken token = default);
|
Task ValidateAnnotations(List<string> annotationNames, bool fromQueue = false, CancellationToken token = default);
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
using System.IO;
|
using System.Net;
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Azaion.Common.DTO;
|
using Azaion.Common.DTO;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -13,115 +14,103 @@ namespace Azaion.Common.Services;
|
|||||||
public interface IAzaionApi
|
public interface IAzaionApi
|
||||||
{
|
{
|
||||||
ApiCredentials Credentials { get; }
|
ApiCredentials Credentials { get; }
|
||||||
User CurrentUser { get; }
|
Task<User> GetCurrentUserAsync();
|
||||||
void UpdateOffsets(UserQueueOffsets offsets);
|
Task UpdateOffsetsAsync(UserQueueOffsets offsets);
|
||||||
//Stream GetResource(string filename, string folder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AzaionApi(ILogger logger, HttpClient client, ICache cache, ApiCredentials credentials) : IAzaionApi
|
public class AzaionApi(ILogger logger, HttpClient client, ICache cache, ApiCredentials credentials) : IAzaionApi
|
||||||
{
|
{
|
||||||
private string _jwtToken = null!;
|
private readonly SemaphoreSlim _authLock = new(1, 1);
|
||||||
|
private string? _jwtToken;
|
||||||
const string APP_JSON = "application/json";
|
const string APP_JSON = "application/json";
|
||||||
|
|
||||||
public ApiCredentials Credentials => credentials;
|
public ApiCredentials Credentials => credentials;
|
||||||
|
|
||||||
public User CurrentUser
|
public async Task<User> GetCurrentUserAsync()
|
||||||
{
|
{
|
||||||
get
|
var user = await cache.GetFromCacheAsync(Constants.CURRENT_USER_CACHE_KEY,
|
||||||
{
|
async () => await GetAsync<User>("users/current"));
|
||||||
var user = cache.GetFromCache(Constants.CURRENT_USER_CACHE_KEY,
|
return user ?? throw new Exception("Can't get current user");
|
||||||
() => Get<User>("users/current"));
|
|
||||||
if (user == null)
|
|
||||||
throw new Exception("Can't get current user");
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateOffsets(UserQueueOffsets offsets)
|
public async Task UpdateOffsetsAsync(UserQueueOffsets offsets)
|
||||||
{
|
{
|
||||||
Put($"/users/queue-offsets/set", new
|
var user = await GetCurrentUserAsync();
|
||||||
{
|
await PutAsync("/users/queue-offsets/set", new { Email = user.Email, Offsets = offsets });
|
||||||
Email = CurrentUser.Email,
|
|
||||||
Offsets = offsets
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpResponseMessage Send(HttpRequestMessage request)
|
private async Task<T?> GetAsync<T>(string url)
|
||||||
|
{
|
||||||
|
var response = await SendWithAuthAsync(() => client.GetAsync(url));
|
||||||
|
return JsonConvert.DeserializeObject<T>(await response.Content.ReadAsStringAsync());
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task PutAsync<T>(string url, T obj)
|
||||||
|
{
|
||||||
|
var content = new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, APP_JSON);
|
||||||
|
await SendWithAuthAsync(() => client.PutAsync(url, content));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<HttpResponseMessage> SendWithAuthAsync(Func<Task<HttpResponseMessage>> sendAction)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_jwtToken))
|
if (string.IsNullOrEmpty(_jwtToken))
|
||||||
Authorize();
|
await AuthorizeAsync();
|
||||||
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _jwtToken);
|
|
||||||
var response = client.Send(request);
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _jwtToken);
|
||||||
|
var response = await sendAction();
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.Unauthorized)
|
if (response.StatusCode == HttpStatusCode.Unauthorized)
|
||||||
{
|
{
|
||||||
Authorize();
|
await AuthorizeAsync();
|
||||||
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _jwtToken);
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _jwtToken);
|
||||||
response = client.Send(request);
|
response = await sendAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
return response;
|
{
|
||||||
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
var stream = response.Content.ReadAsStream();
|
|
||||||
var content = new StreamReader(stream).ReadToEnd();
|
|
||||||
if (response.StatusCode == HttpStatusCode.Conflict)
|
if (response.StatusCode == HttpStatusCode.Conflict)
|
||||||
{
|
{
|
||||||
var result = JsonConvert.DeserializeObject<BusinessExceptionDto>(content);
|
var error = JsonConvert.DeserializeObject<BusinessExceptionDto>(content);
|
||||||
throw new Exception($"Failed: {response.StatusCode}! Error Code: {result?.ErrorCode}. Message: {result?.Message}");
|
throw new Exception($"Failed: {response.StatusCode}! Error Code: {error?.ErrorCode}. Message: {error?.Message}");
|
||||||
}
|
}
|
||||||
throw new Exception($"Failed: {response.StatusCode}! Result: {content}");
|
throw new Exception($"Failed: {response.StatusCode}! Result: {content}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private T? Get<T>(string url)
|
return response;
|
||||||
{
|
|
||||||
var response = Send(new HttpRequestMessage(HttpMethod.Get, url));
|
|
||||||
var stream = response.Content.ReadAsStream();
|
|
||||||
var json = new StreamReader(stream).ReadToEnd();
|
|
||||||
return JsonConvert.DeserializeObject<T>(json);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Put<T>(string url, T obj)
|
private async Task AuthorizeAsync()
|
||||||
{
|
|
||||||
Send(new HttpRequestMessage(HttpMethod.Put, url)
|
|
||||||
{
|
|
||||||
Content = new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, APP_JSON)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Authorize()
|
|
||||||
{
|
{
|
||||||
|
await _authLock.WaitAsync();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(credentials.Email) || credentials.Password.Length == 0)
|
if (string.IsNullOrEmpty(credentials.Email) || credentials.Password.Length == 0)
|
||||||
throw new Exception("Email or password is empty! Please do EnterCredentials first!");
|
throw new Exception("Email or password is empty!");
|
||||||
|
|
||||||
var payload = new
|
var content = new StringContent(
|
||||||
{
|
JsonConvert.SerializeObject(new { email = credentials.Email, password = credentials.Password }),
|
||||||
email = credentials.Email,
|
Encoding.UTF8, APP_JSON);
|
||||||
password = credentials.Password
|
|
||||||
};
|
client.DefaultRequestHeaders.Authorization = null;
|
||||||
var content = new StringContent(JsonConvert.SerializeObject(payload), Encoding.UTF8, APP_JSON);
|
var response = await client.PostAsync("login", content);
|
||||||
var message = new HttpRequestMessage(HttpMethod.Post, "login") { Content = content };
|
|
||||||
var response = client.Send(message);
|
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
throw new Exception($"EnterCredentials failed: {response.StatusCode}");
|
throw new Exception($"Authorization failed: {response.StatusCode}");
|
||||||
|
|
||||||
var stream = response.Content.ReadAsStream();
|
var result = JsonConvert.DeserializeObject<LoginResponse>(await response.Content.ReadAsStringAsync())
|
||||||
var json = new StreamReader(stream).ReadToEnd();
|
?? throw new Exception("JWT Token not found in response");
|
||||||
var result = JsonConvert.DeserializeObject<LoginResponse>(json);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(result?.Token))
|
_jwtToken = result.Token ?? throw new Exception("JWT Token not found in response");
|
||||||
throw new Exception("JWT Token not found in response");
|
|
||||||
|
|
||||||
_jwtToken = result.Token;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.Error(e, e.Message);
|
logger.Error(e, e.Message);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_authLock.Release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace Azaion.Common.Services;
|
|||||||
public interface ICache
|
public interface ICache
|
||||||
{
|
{
|
||||||
T GetFromCache<T>(string key, Func<T> fetchFunc, TimeSpan? expiration = null);
|
T GetFromCache<T>(string key, Func<T> fetchFunc, TimeSpan? expiration = null);
|
||||||
|
Task<T> GetFromCacheAsync<T>(string key, Func<Task<T>> fetchFunc, TimeSpan? expiration = null);
|
||||||
void Invalidate(string key);
|
void Invalidate(string key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,5 +24,16 @@ public class MemoryCache : ICache
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<T> GetFromCacheAsync<T>(string key, Func<Task<T>> fetchFunc, TimeSpan? expiration = null)
|
||||||
|
{
|
||||||
|
expiration ??= TimeSpan.FromHours(4);
|
||||||
|
return await _cache.GetOrAddAsync(key, async entry =>
|
||||||
|
{
|
||||||
|
var result = await fetchFunc();
|
||||||
|
entry.AbsoluteExpirationRelativeToNow = expiration;
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void Invalidate(string key) => _cache.Remove(key);
|
public void Invalidate(string key) => _cache.Remove(key);
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,7 @@ public class FailsafeAnnotationsProducer
|
|||||||
private async Task ProcessQueue(CancellationToken ct = default)
|
private async Task ProcessQueue(CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
_annotationProducer = await Producer.Create(new ProducerConfig(await GetProducerQueueConfig(), Constants.MQ_ANNOTATIONS_QUEUE));
|
_annotationProducer = await Producer.Create(new ProducerConfig(await GetProducerQueueConfig(), Constants.MQ_ANNOTATIONS_QUEUE));
|
||||||
|
var currentUser = await _azaionApi.GetCurrentUserAsync();
|
||||||
while (!ct.IsCancellationRequested)
|
while (!ct.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
var sent = false;
|
var sent = false;
|
||||||
@@ -81,7 +82,7 @@ public class FailsafeAnnotationsProducer
|
|||||||
var appProperties = new ApplicationProperties
|
var appProperties = new ApplicationProperties
|
||||||
{
|
{
|
||||||
{ nameof(AnnotationStatus), record.Operation.ToString() },
|
{ nameof(AnnotationStatus), record.Operation.ToString() },
|
||||||
{ nameof(User.Email), _azaionApi.CurrentUser.Email }
|
{ nameof(User.Email), currentUser.Email }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (record.Operation.In(AnnotationStatus.Validated, AnnotationStatus.Deleted))
|
if (record.Operation.In(AnnotationStatus.Validated, AnnotationStatus.Deleted))
|
||||||
@@ -90,7 +91,7 @@ public class FailsafeAnnotationsProducer
|
|||||||
{
|
{
|
||||||
AnnotationNames = record.AnnotationNames.ToArray(),
|
AnnotationNames = record.AnnotationNames.ToArray(),
|
||||||
AnnotationStatus = record.Operation,
|
AnnotationStatus = record.Operation,
|
||||||
Email = _azaionApi.CurrentUser.Email,
|
Email = currentUser.Email,
|
||||||
CreatedDate = record.DateTime
|
CreatedDate = record.DateTime
|
||||||
})) { ApplicationProperties = appProperties };
|
})) { ApplicationProperties = appProperties };
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.IO.Hashing;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Azaion.Common.Services;
|
||||||
|
|
||||||
|
public static class HashExtensions
|
||||||
|
{
|
||||||
|
private const int SampleSize = 1024;
|
||||||
|
private const int HashLength = 9;
|
||||||
|
private const string VirtualHashPrefix = "V";
|
||||||
|
|
||||||
|
public static string CalcHash(this FileInfo file)
|
||||||
|
{
|
||||||
|
if (!file.Exists)
|
||||||
|
return CalcVirtualHash(file.Name);
|
||||||
|
|
||||||
|
var fileSize = file.Length;
|
||||||
|
if (fileSize < SampleSize * 8)
|
||||||
|
return CalcHashInner(File.ReadAllBytes(file.FullName));
|
||||||
|
|
||||||
|
var combinedData = new byte[8 + SampleSize * 3];
|
||||||
|
var offset = 0;
|
||||||
|
|
||||||
|
var fileSizeBytes = BitConverter.GetBytes(fileSize);
|
||||||
|
Array.Copy(fileSizeBytes, 0, combinedData, offset, 8);
|
||||||
|
offset += 8;
|
||||||
|
|
||||||
|
using var stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
|
||||||
|
stream.ReadExactly(combinedData, offset, SampleSize);
|
||||||
|
offset += SampleSize;
|
||||||
|
|
||||||
|
stream.Position = (fileSize - SampleSize) / 2;
|
||||||
|
stream.ReadExactly(combinedData, offset, SampleSize);
|
||||||
|
offset += SampleSize;
|
||||||
|
|
||||||
|
stream.Position = fileSize - SampleSize;
|
||||||
|
stream.ReadExactly(combinedData, offset, SampleSize);
|
||||||
|
|
||||||
|
return CalcHashInner(combinedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string CalcVirtualHash(string filename)
|
||||||
|
{
|
||||||
|
var bytes = Encoding.UTF8.GetBytes($"VIRTUAL:{filename}");
|
||||||
|
var hash = XxHash64.HashToUInt64(bytes);
|
||||||
|
var hashBytes = BitConverter.GetBytes(hash);
|
||||||
|
var base64 = Convert.ToBase64String(hashBytes);
|
||||||
|
return VirtualHashPrefix + base64[..HashLength];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsVirtualHash(this string? hash) =>
|
||||||
|
!string.IsNullOrEmpty(hash) && hash.StartsWith(VirtualHashPrefix);
|
||||||
|
|
||||||
|
private static string CalcHashInner(byte[] data)
|
||||||
|
{
|
||||||
|
var hash = XxHash64.HashToUInt64(data);
|
||||||
|
var hashBytes = BitConverter.GetBytes(hash);
|
||||||
|
var base64 = Convert.ToBase64String(hashBytes);
|
||||||
|
return base64[..HashLength];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,6 +77,7 @@ public class InferenceClient : IInferenceClient
|
|||||||
{
|
{
|
||||||
case CommandType.InferenceData:
|
case CommandType.InferenceData:
|
||||||
var annotationImage = MessagePackSerializer.Deserialize<AnnotationImage>(remoteCommand.Data, cancellationToken: ct);
|
var annotationImage = MessagePackSerializer.Deserialize<AnnotationImage>(remoteCommand.Data, cancellationToken: ct);
|
||||||
|
_logger.LogInformation("Received command: {AnnotationImage}", annotationImage.ToString());
|
||||||
await _mediator.Publish(new InferenceDataEvent(annotationImage), ct);
|
await _mediator.Publish(new InferenceDataEvent(annotationImage), ct);
|
||||||
break;
|
break;
|
||||||
case CommandType.InferenceStatus:
|
case CommandType.InferenceStatus:
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
using Azaion.Common.Database;
|
|
||||||
using Azaion.Common.DTO;
|
|
||||||
using Azaion.Common.Events;
|
using Azaion.Common.Events;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using MessagePack;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace Azaion.Common.Services.Inference;
|
namespace Azaion.Common.Services.Inference;
|
||||||
|
|
||||||
public class InferenceServiceEventHandler(IInferenceService inferenceService, IAnnotationService annotationService, IMediator mediator) :
|
public class InferenceServiceEventHandler(
|
||||||
|
IInferenceService inferenceService,
|
||||||
|
IAnnotationService annotationService,
|
||||||
|
IMediator mediator) :
|
||||||
INotificationHandler<InferenceDataEvent>,
|
INotificationHandler<InferenceDataEvent>,
|
||||||
INotificationHandler<InferenceStatusEvent>,
|
INotificationHandler<InferenceStatusEvent>,
|
||||||
INotificationHandler<InferenceDoneEvent>
|
INotificationHandler<InferenceDoneEvent>
|
||||||
{
|
{
|
||||||
|
|
||||||
public async Task Handle(InferenceDataEvent e, CancellationToken ct)
|
public async Task Handle(InferenceDataEvent e, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var annotation = await annotationService.SaveAnnotation(e.AnnotationImage, ct);
|
var annotation = await annotationService.SaveAnnotation(e.AnnotationImage, ct);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
@@ -7,7 +6,6 @@ using Azaion.Common.DTO;
|
|||||||
using Azaion.Common.DTO.Config;
|
using Azaion.Common.DTO.Config;
|
||||||
using Azaion.Common.Events;
|
using Azaion.Common.Events;
|
||||||
using Azaion.Common.Extensions;
|
using Azaion.Common.Extensions;
|
||||||
using Azaion.CommonSecurity;
|
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|||||||
@@ -258,12 +258,13 @@ public partial class DatasetExplorer
|
|||||||
private async Task ReloadThumbnails()
|
private async Task ReloadThumbnails()
|
||||||
{
|
{
|
||||||
var withDetectionsOnly = ShowWithObjectsOnlyChBox.IsChecked;
|
var withDetectionsOnly = ShowWithObjectsOnlyChBox.IsChecked;
|
||||||
|
var currentUser = await _azaionApi.GetCurrentUserAsync();
|
||||||
SelectedAnnotations.Clear();
|
SelectedAnnotations.Clear();
|
||||||
SelectedAnnotationDict.Clear();
|
SelectedAnnotationDict.Clear();
|
||||||
var annThumbnails = _annotationsDict[ExplorerEditor.CurrentAnnClass.YoloId]
|
var annThumbnails = _annotationsDict[ExplorerEditor.CurrentAnnClass!.YoloId]
|
||||||
.WhereIf(withDetectionsOnly, x => x.Value.Detections.Any())
|
.WhereIf(withDetectionsOnly, x => x.Value.Detections.Any())
|
||||||
.WhereIf(!string.IsNullOrEmpty(CurrentFilter), x => x.Key.Contains(CurrentFilter, StringComparison.CurrentCultureIgnoreCase))
|
.WhereIf(!string.IsNullOrEmpty(CurrentFilter), x => x.Key.Contains(CurrentFilter, StringComparison.CurrentCultureIgnoreCase))
|
||||||
.Select(x => new AnnotationThumbnail(x.Value, _azaionApi.CurrentUser.Role.IsValidator()))
|
.Select(x => new AnnotationThumbnail(x.Value, currentUser.Role.IsValidator()))
|
||||||
.OrderBy(x => !x.IsSeed)
|
.OrderBy(x => !x.IsSeed)
|
||||||
.ThenByDescending(x =>x.Annotation.CreatedDate);
|
.ThenByDescending(x =>x.Annotation.CreatedDate);
|
||||||
|
|
||||||
@@ -272,7 +273,6 @@ public partial class DatasetExplorer
|
|||||||
SelectedAnnotations.Add(thumb);
|
SelectedAnnotations.Add(thumb);
|
||||||
SelectedAnnotationDict.Add(thumb.Annotation.Name, thumb);
|
SelectedAnnotationDict.Add(thumb.Annotation.Name, thumb);
|
||||||
}
|
}
|
||||||
await Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ValidateAnnotationsClick(object sender, RoutedEventArgs e)
|
private async void ValidateAnnotationsClick(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class DatasetExplorerEventHandler(
|
|||||||
.Select(x => new Detection(a.Name, x.ToYoloLabel(datasetExplorer.ExplorerEditor.RenderSize, mediaSize)))
|
.Select(x => new Detection(a.Name, x.ToYoloLabel(datasetExplorer.ExplorerEditor.RenderSize, mediaSize)))
|
||||||
.ToList();
|
.ToList();
|
||||||
var index = datasetExplorer.ThumbnailsView.SelectedIndex;
|
var index = datasetExplorer.ThumbnailsView.SelectedIndex;
|
||||||
var annotation = await annotationService.SaveAnnotation(a.OriginalMediaName, a.Name, a.Time, detections, token: token);
|
var annotation = await annotationService.SaveAnnotation(a.MediaHash, a.OriginalMediaName, a.Name, a.Time, detections, token: token);
|
||||||
await ValidateAnnotations([annotation], token);
|
await ValidateAnnotations([annotation], token);
|
||||||
await datasetExplorer.EditAnnotation(index + 1);
|
await datasetExplorer.EditAnnotation(index + 1);
|
||||||
break;
|
break;
|
||||||
@@ -119,9 +119,9 @@ public class DatasetExplorerEventHandler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Handle(AnnotationCreatedEvent notification, CancellationToken token)
|
public async Task Handle(AnnotationCreatedEvent notification, CancellationToken token)
|
||||||
{
|
{
|
||||||
datasetExplorer.Dispatcher.Invoke(() =>
|
await datasetExplorer.Dispatcher.Invoke(async () =>
|
||||||
{
|
{
|
||||||
var annotation = notification.Annotation;
|
var annotation = notification.Annotation;
|
||||||
var selectedClass = datasetExplorer.LvClasses.CurrentClassNumber;
|
var selectedClass = datasetExplorer.LvClasses.CurrentClassNumber;
|
||||||
@@ -131,7 +131,8 @@ public class DatasetExplorerEventHandler(
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var index = 0;
|
var index = 0;
|
||||||
var annThumb = new AnnotationThumbnail(annotation, azaionApi.CurrentUser.Role.IsValidator());
|
var currentUser = await azaionApi.GetCurrentUserAsync();
|
||||||
|
var annThumb = new AnnotationThumbnail(annotation, currentUser.Role.IsValidator());
|
||||||
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
|
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
|
||||||
{
|
{
|
||||||
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
|
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
|
||||||
@@ -146,7 +147,6 @@ public class DatasetExplorerEventHandler(
|
|||||||
datasetExplorer.SelectedAnnotations.Insert(index, annThumb);
|
datasetExplorer.SelectedAnnotations.Insert(index, annThumb);
|
||||||
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
|
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
|
||||||
});
|
});
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken token)
|
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken token)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
"DirectoriesConfig": {
|
"DirectoriesConfig": {
|
||||||
"ApiResourcesDirectory": "stage",
|
"ApiResourcesDirectory": "stage",
|
||||||
"VideosDirectory": "E:\\Azaion6",
|
"VideosDirectory": "E:\\Azaion3\\VideosTest",
|
||||||
"LabelsDirectory": "E:\\labels",
|
"LabelsDirectory": "E:\\labels",
|
||||||
"ImagesDirectory": "E:\\images",
|
"ImagesDirectory": "E:\\images",
|
||||||
"ResultsDirectory": "E:\\results",
|
"ResultsDirectory": "E:\\results",
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
{ "Id": 17, "Name": "Ammo", "ShortName": "БК", "Color": "#33658a", "MaxSizeM": 2 },
|
{ "Id": 17, "Name": "Ammo", "ShortName": "БК", "Color": "#33658a", "MaxSizeM": 2 },
|
||||||
{ "Id": 18, "Name": "Protect.Struct", "ShortName": "Зуби.драк", "Color": "#969647", "MaxSizeM": 2 }
|
{ "Id": 18, "Name": "Protect.Struct", "ShortName": "Зуби.драк", "Color": "#969647", "MaxSizeM": 2 }
|
||||||
],
|
],
|
||||||
"VideoFormats": [ ".mp4", ".mov", ".avi", ".ts", ".mkv" ],
|
|
||||||
"ImageFormats": [ ".jpg", ".jpeg", ".png", ".bmp" ],
|
|
||||||
"AnnotationsDbFile": "annotations.db"
|
"AnnotationsDbFile": "annotations.db"
|
||||||
},
|
},
|
||||||
"AIRecognitionConfig": {
|
"AIRecognitionConfig": {
|
||||||
|
|||||||
Reference in New Issue
Block a user