mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 02:16:29 +00:00
92 lines
2.9 KiB
C#
92 lines
2.9 KiB
C#
using System.IO;
|
|
using System.Text;
|
|
using Azaion.Annotator.DTO;
|
|
using Azaion.Suite.Services.DTO;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Azaion.Common.DTO.Config;
|
|
|
|
public class AppConfig
|
|
{
|
|
public ApiConfig ApiConfig { get; set; } = null!;
|
|
|
|
public AnnotationConfig AnnotationConfig { get; set; } = null!;
|
|
|
|
public WindowConfig WindowConfig { get; set; } = null!;
|
|
|
|
public AIRecognitionConfig AIRecognitionConfig { get; set; } = null!;
|
|
|
|
public DirectoriesConfig DirectoriesConfig { get; set; } = null!;
|
|
|
|
public ThumbnailConfig ThumbnailConfig { get; set; } = null!;
|
|
}
|
|
|
|
public interface IConfigUpdater
|
|
{
|
|
void CheckConfig();
|
|
void Save(AppConfig config);
|
|
}
|
|
|
|
public class ConfigUpdater : IConfigUpdater
|
|
{
|
|
public void CheckConfig()
|
|
{
|
|
var exePath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory)!;
|
|
var configFilePath = Path.Combine(exePath, Constants.CONFIG_PATH);
|
|
|
|
if (File.Exists(configFilePath))
|
|
return;
|
|
|
|
var appConfig = new AppConfig
|
|
{
|
|
AnnotationConfig = new AnnotationConfig
|
|
{
|
|
AnnotationClasses = Constants.DefaultAnnotationClasses,
|
|
VideoFormats = Constants.DefaultVideoFormats,
|
|
ImageFormats = Constants.DefaultImageFormats,
|
|
},
|
|
|
|
WindowConfig = new WindowConfig
|
|
{
|
|
WindowSize = Constants.DefaultWindowSize,
|
|
WindowLocation = Constants.DefaultWindowLocation,
|
|
ShowHelpOnStart = true,
|
|
FullScreen = true,
|
|
LeftPanelWidth = 250,
|
|
RightPanelWidth = 250,
|
|
},
|
|
|
|
DirectoriesConfig = new DirectoriesConfig
|
|
{
|
|
VideosDirectory = Constants.DEFAULT_VIDEO_DIR,
|
|
ImagesDirectory = Constants.DEFAULT_IMAGES_DIR,
|
|
LabelsDirectory = Constants.DEFAULT_LABELS_DIR,
|
|
ResultsDirectory = Constants.DEFAULT_RESULTS_DIR,
|
|
ThumbnailsDirectory = Constants.DEFAULT_THUMBNAILS_DIR
|
|
},
|
|
|
|
ThumbnailConfig = new ThumbnailConfig
|
|
{
|
|
Size = Constants.DefaultThumbnailSize,
|
|
Border = Constants.DEFAULT_THUMBNAIL_BORDER
|
|
},
|
|
|
|
AIRecognitionConfig = new AIRecognitionConfig
|
|
{
|
|
AIModelPath = "azaion.onnx",
|
|
FrameRecognitionSeconds = Constants.DEFAULT_FRAME_RECOGNITION_SECONDS,
|
|
TrackingDistanceConfidence = Constants.TRACKING_DISTANCE_CONFIDENCE,
|
|
TrackingProbabilityIncrease = Constants.TRACKING_PROBABILITY_INCREASE,
|
|
TrackingIntersectionThreshold = Constants.TRACKING_INTERSECTION_THRESHOLD
|
|
}
|
|
};
|
|
Save(appConfig);
|
|
}
|
|
|
|
public void Save(AppConfig config)
|
|
{
|
|
File.WriteAllText(Constants.CONFIG_PATH, JsonConvert.SerializeObject(config, Formatting.Indented), Encoding.UTF8);
|
|
}
|
|
}
|