mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 18:06:39 +00:00
queue + local sqlite WIP
This commit is contained in:
+18
-38
@@ -1,14 +1,16 @@
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Azaion.Annotator;
|
||||
using Azaion.Annotator.Extensions;
|
||||
using Azaion.Common;
|
||||
using Azaion.Common.Database;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.Extensions;
|
||||
using Azaion.Common.Services;
|
||||
using Azaion.CommonSecurity;
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
using Azaion.CommonSecurity.Services;
|
||||
using Azaion.Dataset;
|
||||
using LibVLCSharp.Shared;
|
||||
using MediatR;
|
||||
@@ -17,7 +19,6 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
|
||||
@@ -32,38 +33,7 @@ public partial class App
|
||||
|
||||
private AzaionApiClient _apiClient = null!;
|
||||
private IResourceLoader _resourceLoader = null!;
|
||||
|
||||
private static AzaionApiClient CreateApiClient(ApiCredentials credentials)
|
||||
{
|
||||
ApiConfig apiConfig;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(Constants.CONFIG_PATH))
|
||||
throw new FileNotFoundException(Constants.CONFIG_PATH);
|
||||
var configStr = File.ReadAllText(Constants.CONFIG_PATH);
|
||||
apiConfig = JsonConvert.DeserializeObject<AppConfig>(configStr)!.ApiConfig;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
apiConfig = new ApiConfig
|
||||
{
|
||||
Url = "https://api.azaion.com",
|
||||
RetryCount = 3,
|
||||
TimeoutSeconds = 40
|
||||
};
|
||||
}
|
||||
|
||||
var api = new AzaionApiClient(new HttpClient
|
||||
{
|
||||
BaseAddress = new Uri(apiConfig.Url),
|
||||
Timeout = TimeSpan.FromSeconds(apiConfig.TimeoutSeconds)
|
||||
});
|
||||
|
||||
api.EnterCredentials(credentials);
|
||||
return api;
|
||||
}
|
||||
|
||||
private Stream _securedConfig = null!;
|
||||
|
||||
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
@@ -83,8 +53,9 @@ public partial class App
|
||||
var login = new Login();
|
||||
login.CredentialsEntered += async (s, args) =>
|
||||
{
|
||||
_apiClient = CreateApiClient(args);
|
||||
_apiClient = AzaionApiClient.Create(args);
|
||||
_resourceLoader = new ResourceLoader(_apiClient, args);
|
||||
_securedConfig = await _resourceLoader.Load("secured-config.json");
|
||||
AppDomain.CurrentDomain.AssemblyResolve += (_, a) => _resourceLoader.LoadAssembly(a.Name);
|
||||
|
||||
StartMain();
|
||||
@@ -110,7 +81,8 @@ public partial class App
|
||||
_host = Host.CreateDefaultBuilder()
|
||||
.ConfigureAppConfiguration((context, config) => config
|
||||
.AddCommandLine(Environment.GetCommandLineArgs())
|
||||
.AddJsonFile(Constants.CONFIG_PATH, optional: true, reloadOnChange: true))
|
||||
.AddJsonFile(SecurityConstants.CONFIG_PATH, optional: true, reloadOnChange: true)
|
||||
.AddJsonStream(_securedConfig))
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddSingleton<MainSuite>();
|
||||
@@ -121,9 +93,9 @@ public partial class App
|
||||
|
||||
services.Configure<AppConfig>(context.Configuration);
|
||||
services.ConfigureSection<ApiConfig>(context.Configuration);
|
||||
services.ConfigureSection<QueueConfig>(context.Configuration);
|
||||
services.ConfigureSection<DirectoriesConfig>(context.Configuration);
|
||||
services.ConfigureSection<AnnotationConfig>(context.Configuration);
|
||||
services.ConfigureSection<AnnotatorWindowConfig>(context.Configuration);
|
||||
services.ConfigureSection<AIRecognitionConfig>(context.Configuration);
|
||||
services.ConfigureSection<ThumbnailConfig>(context.Configuration);
|
||||
|
||||
@@ -144,6 +116,7 @@ public partial class App
|
||||
});
|
||||
services.AddSingleton<AnnotatorEventHandler>();
|
||||
services.AddSingleton<VLCFrameExtractor>();
|
||||
services.AddSingleton<IDbFactory, DbFactory>();
|
||||
|
||||
services.AddHttpClient<AzaionApiClient>((sp, client) =>
|
||||
{
|
||||
@@ -152,6 +125,10 @@ public partial class App
|
||||
client.Timeout = TimeSpan.FromSeconds(apiConfig.TimeoutSeconds);
|
||||
});
|
||||
|
||||
services.AddSingleton<FailsafeAnnotationsProducer>();
|
||||
|
||||
services.AddSingleton<AnnotationService>();
|
||||
|
||||
services.AddSingleton<DatasetExplorer>();
|
||||
services.AddSingleton<IGalleryManager, GalleryManager>();
|
||||
|
||||
@@ -159,6 +136,9 @@ public partial class App
|
||||
services.AddSingleton<IAzaionModule, DatasetExplorerModule>();
|
||||
})
|
||||
.Build();
|
||||
|
||||
Annotation.InitializeDirs(_host.Services.GetRequiredService<IOptions<DirectoriesConfig>>().Value);
|
||||
|
||||
_mediator = _host.Services.GetRequiredService<IMediator>();
|
||||
_logger = _host.Services.GetRequiredService<ILogger<App>>();
|
||||
_formState = _host.Services.GetRequiredService<FormState>();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="RabbitMQ.Stream.Client" Version="1.8.9" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
@@ -37,6 +38,9 @@
|
||||
<Content Include="logo.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Update="config.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
BorderBrush="DimGray"
|
||||
BorderThickness="0,0,0,1"
|
||||
HorizontalAlignment="Left"
|
||||
Text="admin@azaion.com"
|
||||
/>
|
||||
<TextBlock Text="Пароль"
|
||||
Grid.Row="2"
|
||||
@@ -87,7 +88,8 @@
|
||||
Padding="0,5"
|
||||
Width="300"
|
||||
BorderThickness="0,0,0,1"
|
||||
HorizontalAlignment="Left"/>
|
||||
HorizontalAlignment="Left"
|
||||
Password="Az@1on1000Odm$n"/>
|
||||
</Grid>
|
||||
<Button x:Name="LoginBtn"
|
||||
Content="Вхід"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
|
||||
namespace Azaion.Suite;
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
Title="Azaion Оператор" Height="60" Width="214"
|
||||
Title="Azaion Оператор" Height="50" Width="214"
|
||||
WindowStyle="None"
|
||||
ResizeMode="NoResize"
|
||||
Top="0"
|
||||
Topmost="True">
|
||||
Topmost="True"
|
||||
MouseMove="OnMouseMove"
|
||||
MouseDown="MainSuite_OnMouseDown">
|
||||
<Grid Background="Black">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="48"></ColumnDefinition>
|
||||
@@ -31,8 +33,8 @@
|
||||
<Border Grid.Column="2">
|
||||
<Button
|
||||
VerticalAlignment="Top"
|
||||
Width="24"
|
||||
Height="24"
|
||||
Width="18"
|
||||
Height="18"
|
||||
ToolTip="Закрити" Background="Black" BorderBrush="Black" Cursor="Hand"
|
||||
Name="CloseBtn"
|
||||
Click="CloseBtn_OnClick">
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Windows.Media;
|
||||
using Azaion.Annotator.Extensions;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.Extensions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SharpVectors.Converters;
|
||||
@@ -33,7 +34,7 @@ public partial class MainSuite
|
||||
SizeChanged += async (_, _) => await SaveUserSettings();
|
||||
LocationChanged += async (_, _) => await SaveUserSettings();
|
||||
StateChanged += async (_, _) => await SaveUserSettings();
|
||||
Left = SystemParameters.WorkArea.Width - Width - 250;
|
||||
Left = (SystemParameters.WorkArea.Width - Width) / 2;
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
@@ -54,8 +55,8 @@ public partial class MainSuite
|
||||
new SvgViewbox
|
||||
{
|
||||
SvgSource = azaionModule.SvgIcon,
|
||||
Width = 32,
|
||||
Height = 32,
|
||||
Width = 24,
|
||||
Height = 24,
|
||||
Margin = new Thickness(0, 0, 10, 0)
|
||||
},
|
||||
new TextBlock
|
||||
@@ -120,4 +121,20 @@ public partial class MainSuite
|
||||
}
|
||||
|
||||
private void CloseBtn_OnClick(object sender, RoutedEventArgs e) => Close();
|
||||
|
||||
private double _startMouseMovePosition;
|
||||
|
||||
private void OnMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.OriginalSource is Button || e.OriginalSource is StackPanel)
|
||||
return;
|
||||
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
Left = System.Windows.Forms.Cursor.Position.X - _startMouseMovePosition;
|
||||
}
|
||||
|
||||
private void MainSuite_OnMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
_startMouseMovePosition = e.GetPosition(this).X;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,18 @@
|
||||
{
|
||||
"ApiConfig": {
|
||||
"Url": "https://api.azaion.com",
|
||||
"TimeoutSeconds": 20,
|
||||
"RetryCount": 3
|
||||
"Url": "https://api.azaion.com/",
|
||||
"RetryCount": 3,
|
||||
"TimeoutSeconds": 40.0,
|
||||
"TokenFile": "token.txt"
|
||||
},
|
||||
|
||||
"DirectoriesConfig": {
|
||||
"VideosDirectory" : "E:\\Azaion1\\Videos",
|
||||
"LabelsDirectory" : "E:\\labels",
|
||||
"ImagesDirectory" : "E:\\images",
|
||||
"ResultsDirectory" : "E:\\results",
|
||||
"ThumbnailsDirectory" : "E:\\thumbnails",
|
||||
|
||||
"DllCacheDirectory" : "Cache"
|
||||
"VideosDirectory": "E:\\Azaion6",
|
||||
"LabelsDirectory": "E:\\labels",
|
||||
"ImagesDirectory": "E:\\images",
|
||||
"ResultsDirectory": "E:\\results",
|
||||
"ThumbnailsDirectory": "E:\\thumbnails"
|
||||
},
|
||||
|
||||
"AnnotationConfig" : {
|
||||
"AnnotationConfig": {
|
||||
"AnnotationClasses": [
|
||||
{ "Id": 0, "Name": "Броньована техніка", "ShortName": "Бронь" },
|
||||
{ "Id": 1, "Name": "Вантажівка", "ShortName": "Вантаж" },
|
||||
@@ -27,32 +24,22 @@
|
||||
{ "Id": 7, "Name": "Накати", "ShortName": "Накати" },
|
||||
{ "Id": 8, "Name": "Танк з захистом", "ShortName": "Танк захист" },
|
||||
{ "Id": 9, "Name": "Дим", "ShortName": "Дим" },
|
||||
{ "Id": 10, "Name": "Літак", "ShortName": "Літак" }
|
||||
{ "Id": 10, "Name": "Літак", "ShortName": "Літак" },
|
||||
{ "Id": 11, "Name": "Мотоцикл", "ShortName": "Мото" }
|
||||
],
|
||||
"LastSelectedExplorerClass": 1,
|
||||
"VideoFormats": ["mov", "mp4"],
|
||||
"ImageFormats": ["jpg", "jpeg", "png", "bmp", "gif"]
|
||||
"LastSelectedExplorerClass": null,
|
||||
"VideoFormats": [ "mp4", "mov", "avi" ],
|
||||
"ImageFormats": [ "jpg", "jpeg", "png", "bmp" ],
|
||||
"AnnotationsDbFile": "annotations.db",
|
||||
"LeftPanelWidth": 220.0,
|
||||
"RightPanelWidth": 230.0
|
||||
},
|
||||
|
||||
"WindowConfig": {
|
||||
"WindowSize": "1920,1080",
|
||||
"WindowLocation": "50,50",
|
||||
"FullScreen": true,
|
||||
"LeftPanelWidth": 220,
|
||||
"RightPanelWidth": 220,
|
||||
"ShowHelpOnStart": false
|
||||
},
|
||||
|
||||
"AIRecognitionConfig": {
|
||||
"FrameRecognitionSeconds" : 2,
|
||||
"TrackingDistanceConfidence" : 0.15,
|
||||
"TrackingProbabilityIncrease" : 15,
|
||||
"TrackingIntersectionThreshold" : 0.8,
|
||||
"FrameRecognitionSeconds": 2.0,
|
||||
"TrackingDistanceConfidence": 0.15,
|
||||
"TrackingProbabilityIncrease": 15.0,
|
||||
"TrackingIntersectionThreshold": 0.8,
|
||||
"FramePeriodRecognition": 4
|
||||
},
|
||||
|
||||
"ThumbnailConfig": {
|
||||
"Size" : "240,135",
|
||||
"Border" : 10
|
||||
}
|
||||
"ThumbnailConfig": { "Size": "240,135", "Border": 10 }
|
||||
}
|
||||
Reference in New Issue
Block a user