forked from amkovkov/GranuSightSoftware2
fix: typos
TOO many typos
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
using GSS2.Core.Extentions;
|
using GSS2.Core.Extensions;
|
||||||
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace GSS2.Core.Extentions;
|
namespace GSS2.Core.Extensions;
|
||||||
|
|
||||||
public static class ConfiurationSectionExtensions
|
public static class ConfigurationSectionExtensions
|
||||||
{
|
{
|
||||||
public static Dictionary<string, string> AsDictionary(this IConfigurationSection values)
|
public static Dictionary<string, string> AsDictionary(this IConfigurationSection values)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
namespace GSS2.Core.Extentions;
|
namespace GSS2.Core.Extensions;
|
||||||
|
|
||||||
public static class EnumerableExtensions
|
public static class EnumerableExtensions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using Microsoft.Extensions.Configuration;
|
|||||||
|
|
||||||
using LibCameraSharp;
|
using LibCameraSharp;
|
||||||
|
|
||||||
using GSS2.Core.Extentions;
|
using GSS2.Core.Extensions;
|
||||||
using GSS2.Core.Abstractions;
|
using GSS2.Core.Abstractions;
|
||||||
using GSS2.Core.Helpers;
|
using GSS2.Core.Helpers;
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ public class CameraService : IDisposable
|
|||||||
private List<MappedBuffer>? _imageCaptureMappedBuffers;
|
private List<MappedBuffer>? _imageCaptureMappedBuffers;
|
||||||
private System.Timers.Timer? _viewFinderTimer = null;
|
private System.Timers.Timer? _viewFinderTimer = null;
|
||||||
private System.Timers.ElapsedEventHandler? _viewFinderTimerElapsed = null;
|
private System.Timers.ElapsedEventHandler? _viewFinderTimerElapsed = null;
|
||||||
private EventHandler<Camera.RequestCompletedEventArgs>? _viewFinderRequestComplitedHandler = null;
|
private EventHandler<Camera.RequestCompletedEventArgs>? _viewFinderRequestCompletedHandler = null;
|
||||||
private readonly CancellationTokenSource _disposeCts = new CancellationTokenSource();
|
private readonly CancellationTokenSource _disposeCts = new CancellationTokenSource();
|
||||||
private readonly Dictionary<string, object> _cameraHardSettings = new Dictionary<string, object>();
|
private readonly Dictionary<string, object> _cameraHardSettings = new Dictionary<string, object>();
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ public class CameraService : IDisposable
|
|||||||
cts.Task.WaitAsync(cancellationToken).GetAwaiter().GetResult();
|
cts.Task.WaitAsync(cancellationToken).GetAwaiter().GetResult();
|
||||||
_camera.RequestCompleted -= RequestCompleted;
|
_camera.RequestCompleted -= RequestCompleted;
|
||||||
|
|
||||||
_logger.LogDebug("Request complited: \n\tResult: {} \n\tStatus: {} \n\tCookie: {} \n\tSequence: {} \n\tHasPendingBuffers: {}", result, request.Status, request.Cookie, request.Sequence, request.HasPendingBuffers);
|
_logger.LogDebug("Request completed: \n\tResult: {} \n\tStatus: {} \n\tCookie: {} \n\tSequence: {} \n\tHasPendingBuffers: {}", result, request.Status, request.Cookie, request.Sequence, request.HasPendingBuffers);
|
||||||
_logger.LogDebug("Request buffer: \n\tStatus: {} \n\tCookie: {} \n\tSequence: {} \n\tTimestamp: {}", buffer.Metadata.Status, buffer.Cookie, buffer.Metadata.Sequence, buffer.Metadata.Timestamp);
|
_logger.LogDebug("Request buffer: \n\tStatus: {} \n\tCookie: {} \n\tSequence: {} \n\tTimestamp: {}", buffer.Metadata.Status, buffer.Cookie, buffer.Metadata.Sequence, buffer.Metadata.Timestamp);
|
||||||
_logger.LogDebug("Request buffer planes: ");
|
_logger.LogDebug("Request buffer planes: ");
|
||||||
foreach (var (i, plane) in buffer.Metadata.Planes.Enumerate())
|
foreach (var (i, plane) in buffer.Metadata.Planes.Enumerate())
|
||||||
@@ -452,7 +452,7 @@ public class CameraService : IDisposable
|
|||||||
cts.Task.WaitAsync(cancellationToken).GetAwaiter().GetResult();
|
cts.Task.WaitAsync(cancellationToken).GetAwaiter().GetResult();
|
||||||
_camera.RequestCompleted -= RequestCompleted;
|
_camera.RequestCompleted -= RequestCompleted;
|
||||||
|
|
||||||
_logger.LogDebug("Request complited: \n\tResult: {} \n\tStatus: {}\n\tCookie: {}\n\tSequence: {}\n\tHasPendingBuffers: {}", result, request.Status, request.Cookie, request.Sequence, request.HasPendingBuffers);
|
_logger.LogDebug("Request completed: \n\tResult: {} \n\tStatus: {}\n\tCookie: {}\n\tSequence: {}\n\tHasPendingBuffers: {}", result, request.Status, request.Cookie, request.Sequence, request.HasPendingBuffers);
|
||||||
_logger.LogDebug("Request buffer: \n\tStatus: {} \n\tCookie: {} \n\tSequence: {} \n\tTimestamp: {}", buffer.Metadata.Status, buffer.Cookie, buffer.Metadata.Sequence, buffer.Metadata.Timestamp);
|
_logger.LogDebug("Request buffer: \n\tStatus: {} \n\tCookie: {} \n\tSequence: {} \n\tTimestamp: {}", buffer.Metadata.Status, buffer.Cookie, buffer.Metadata.Sequence, buffer.Metadata.Timestamp);
|
||||||
foreach (var (i, plane) in buffer.Metadata.Planes.Enumerate())
|
foreach (var (i, plane) in buffer.Metadata.Planes.Enumerate())
|
||||||
_logger.LogDebug("Plane[{}]: bytes used: 0x{:X}", i, plane.BytesUsed);
|
_logger.LogDebug("Plane[{}]: bytes used: 0x{:X}", i, plane.BytesUsed);
|
||||||
@@ -705,7 +705,7 @@ public class CameraService : IDisposable
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogDebug("Request complited: \n\tStatus: {}\n\tCookie: {}\n\tSequence: {}\n\tHasPendingBuffers: {}", e.Request.Status, e.Request.Cookie, e.Request.Sequence, e.Request.HasPendingBuffers);
|
_logger.LogDebug("Request completed: \n\tStatus: {}\n\tCookie: {}\n\tSequence: {}\n\tHasPendingBuffers: {}", e.Request.Status, e.Request.Cookie, e.Request.Sequence, e.Request.HasPendingBuffers);
|
||||||
_logger.LogDebug("Request buffer: \n\tStatus: {} \n\tCookie: {} \n\tSequence: {} \n\tTimestamp: {}", buffer.Metadata.Status, buffer.Cookie, buffer.Metadata.Sequence, buffer.Metadata.Timestamp);
|
_logger.LogDebug("Request buffer: \n\tStatus: {} \n\tCookie: {} \n\tSequence: {} \n\tTimestamp: {}", buffer.Metadata.Status, buffer.Cookie, buffer.Metadata.Sequence, buffer.Metadata.Timestamp);
|
||||||
_logger.LogDebug("Request buffer planes: ");
|
_logger.LogDebug("Request buffer planes: ");
|
||||||
foreach (var (i, plane) in buffer.Metadata.Planes.Enumerate())
|
foreach (var (i, plane) in buffer.Metadata.Planes.Enumerate())
|
||||||
@@ -759,7 +759,7 @@ public class CameraService : IDisposable
|
|||||||
}
|
}
|
||||||
_logger.LogDebug("{} request(s) queued", requests.Count());
|
_logger.LogDebug("{} request(s) queued", requests.Count());
|
||||||
await cts.Task.WaitAsync(effectiveCancellationToken);
|
await cts.Task.WaitAsync(effectiveCancellationToken);
|
||||||
_logger.LogDebug("{} request(s) compilted", requests.Count());
|
_logger.LogDebug("{} request(s) completed", requests.Count());
|
||||||
_camera.RequestCompleted -= RequestCompleted;
|
_camera.RequestCompleted -= RequestCompleted;
|
||||||
|
|
||||||
foreach (var key in fdsData.Keys)
|
foreach (var key in fdsData.Keys)
|
||||||
@@ -837,7 +837,7 @@ public class CameraService : IDisposable
|
|||||||
throw new InvalidOperationException("ViewFinderFrameBufferAllocator not initialized");
|
throw new InvalidOperationException("ViewFinderFrameBufferAllocator not initialized");
|
||||||
if (_viewFinderTimer is not null ||
|
if (_viewFinderTimer is not null ||
|
||||||
_viewFinderTimerElapsed is not null ||
|
_viewFinderTimerElapsed is not null ||
|
||||||
_viewFinderRequestComplitedHandler is not null)
|
_viewFinderRequestCompletedHandler is not null)
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
|
|
||||||
_viewFinderTimer = new System.Timers.Timer()
|
_viewFinderTimer = new System.Timers.Timer()
|
||||||
@@ -858,12 +858,12 @@ public class CameraService : IDisposable
|
|||||||
if (ea.Request.Cookie != 2)
|
if (ea.Request.Cookie != 2)
|
||||||
return;
|
return;
|
||||||
var buffer = ea.Request.FindBuffer(_viewFinderStream);
|
var buffer = ea.Request.FindBuffer(_viewFinderStream);
|
||||||
// _logger.LogInformation("Complited request for frame buffer {}", buffer);
|
// _logger.LogInformation("Completed request for frame buffer {}", buffer);
|
||||||
lock (ViewFinderBufferQueue)
|
lock (ViewFinderBufferQueue)
|
||||||
ViewFinderBufferQueue.Add(buffer);
|
ViewFinderBufferQueue.Add(buffer);
|
||||||
}
|
}
|
||||||
_viewFinderRequestComplitedHandler = RequestCompleted;
|
_viewFinderRequestCompletedHandler = RequestCompleted;
|
||||||
_camera.RequestCompleted += _viewFinderRequestComplitedHandler;
|
_camera.RequestCompleted += _viewFinderRequestCompletedHandler;
|
||||||
|
|
||||||
void TimerElapsed(object? sender, System.Timers.ElapsedEventArgs ea)
|
void TimerElapsed(object? sender, System.Timers.ElapsedEventArgs ea)
|
||||||
{
|
{
|
||||||
@@ -911,8 +911,8 @@ public class CameraService : IDisposable
|
|||||||
_viewFinderTimer.Dispose();
|
_viewFinderTimer.Dispose();
|
||||||
_viewFinderTimer = null;
|
_viewFinderTimer = null;
|
||||||
_viewFinderTimerElapsed = null;
|
_viewFinderTimerElapsed = null;
|
||||||
_camera.RequestCompleted -= _viewFinderRequestComplitedHandler;
|
_camera.RequestCompleted -= _viewFinderRequestCompletedHandler;
|
||||||
_viewFinderRequestComplitedHandler = null;
|
_viewFinderRequestCompletedHandler = null;
|
||||||
lock (ViewFinderBufferQueue)
|
lock (ViewFinderBufferQueue)
|
||||||
ViewFinderBufferQueue.Clear();
|
ViewFinderBufferQueue.Clear();
|
||||||
}
|
}
|
||||||
@@ -922,8 +922,8 @@ public class CameraService : IDisposable
|
|||||||
_viewFinderTimer?.Stop();
|
_viewFinderTimer?.Stop();
|
||||||
_viewFinderTimer?.Dispose();
|
_viewFinderTimer?.Dispose();
|
||||||
_viewFinderTimer = null;
|
_viewFinderTimer = null;
|
||||||
_camera?.RequestCompleted -= _viewFinderRequestComplitedHandler;
|
_camera?.RequestCompleted -= _viewFinderRequestCompletedHandler;
|
||||||
_viewFinderRequestComplitedHandler = null;
|
_viewFinderRequestCompletedHandler = null;
|
||||||
lock (ViewFinderBufferQueue)
|
lock (ViewFinderBufferQueue)
|
||||||
ViewFinderBufferQueue.Clear();
|
ViewFinderBufferQueue.Clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
using GSS2.Core.Extentions;
|
using GSS2.Core.Extensions;
|
||||||
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public class ComputeResourcesService
|
|||||||
}
|
}
|
||||||
private CpuUsage GetCpuUsage()
|
private CpuUsage GetCpuUsage()
|
||||||
{
|
{
|
||||||
static (double usage, long idle, long total) ParceLines(string line, (long idle, long total)? prev)
|
static (double usage, long idle, long total) ParseLines(string line, (long idle, long total)? prev)
|
||||||
{
|
{
|
||||||
var parts = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
var parts = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||||
long user = long.Parse(parts[1]);
|
long user = long.Parse(parts[1]);
|
||||||
@@ -82,7 +82,7 @@ public class ComputeResourcesService
|
|||||||
if (lines.Count() == 0)
|
if (lines.Count() == 0)
|
||||||
return new CpuUsage(0, new List<double>());
|
return new CpuUsage(0, new List<double>());
|
||||||
|
|
||||||
var (allUsage, allIdle, allTotal) = ParceLines(lines.First(), _prevAll);
|
var (allUsage, allIdle, allTotal) = ParseLines(lines.First(), _prevAll);
|
||||||
_prevAll = (allIdle, allTotal);
|
_prevAll = (allIdle, allTotal);
|
||||||
|
|
||||||
var coreUsages = new List<double>();
|
var coreUsages = new List<double>();
|
||||||
@@ -93,7 +93,7 @@ public class ComputeResourcesService
|
|||||||
_prevCores = new Dictionary<int, (long idle, long total)?>();
|
_prevCores = new Dictionary<int, (long idle, long total)?>();
|
||||||
if (!_prevCores.ContainsKey(i))
|
if (!_prevCores.ContainsKey(i))
|
||||||
_prevCores.Add(i, null);
|
_prevCores.Add(i, null);
|
||||||
var (coreUsage, coreIdle, coreTotal) = ParceLines(line, _prevCores[i]);
|
var (coreUsage, coreIdle, coreTotal) = ParseLines(line, _prevCores[i]);
|
||||||
_prevCores[i] = (coreIdle, coreTotal);
|
_prevCores[i] = (coreIdle, coreTotal);
|
||||||
coreUsages.Add(coreUsage);
|
coreUsages.Add(coreUsage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ public class IlluminatorService : IDisposable
|
|||||||
private readonly GpioPin _uv365Relay;
|
private readonly GpioPin _uv365Relay;
|
||||||
private readonly GpioPin _fanRelay;
|
private readonly GpioPin _fanRelay;
|
||||||
|
|
||||||
public event EventHandler<double>? WhiteIntencityChanged;
|
public event EventHandler<double>? WhiteIntensityChanged;
|
||||||
public event EventHandler<double>? Uv254IntencityChanged;
|
public event EventHandler<double>? Uv254IntensityChanged;
|
||||||
public event EventHandler<double>? Uv365IntencityChanged;
|
public event EventHandler<double>? Uv365IntensityChanged;
|
||||||
|
|
||||||
public IlluminatorService(ILogger<IlluminatorService> logger, IlluminatorServiceConfiguration? configuration = null)
|
public IlluminatorService(ILogger<IlluminatorService> logger, IlluminatorServiceConfiguration? configuration = null)
|
||||||
{
|
{
|
||||||
@@ -125,17 +125,17 @@ public class IlluminatorService : IDisposable
|
|||||||
if (white is not null)
|
if (white is not null)
|
||||||
{
|
{
|
||||||
_whitePwm.DutyCycle = CalculateDuty(white.Value, _configuration.MaxWhitePwmDuty);
|
_whitePwm.DutyCycle = CalculateDuty(white.Value, _configuration.MaxWhitePwmDuty);
|
||||||
WhiteIntencityChanged?.Invoke(this, white.Value);
|
WhiteIntensityChanged?.Invoke(this, white.Value);
|
||||||
}
|
}
|
||||||
if (uv365 is not null)
|
if (uv365 is not null)
|
||||||
{
|
{
|
||||||
_uv365Pwm.DutyCycle = CalculateDuty(uv365.Value, _configuration.MaxUv365PwmDuty);
|
_uv365Pwm.DutyCycle = CalculateDuty(uv365.Value, _configuration.MaxUv365PwmDuty);
|
||||||
Uv365IntencityChanged?.Invoke(this, uv365.Value);
|
Uv365IntensityChanged?.Invoke(this, uv365.Value);
|
||||||
}
|
}
|
||||||
if (uv254 is not null)
|
if (uv254 is not null)
|
||||||
{
|
{
|
||||||
_uv254Pwm.DutyCycle = CalculateDuty(uv254.Value, _configuration.MaxUv254PwmDuty);
|
_uv254Pwm.DutyCycle = CalculateDuty(uv254.Value, _configuration.MaxUv254PwmDuty);
|
||||||
Uv254IntencityChanged?.Invoke(this, uv254.Value);
|
Uv254IntensityChanged?.Invoke(this, uv254.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public static class ControlValueHelper
|
|||||||
{ typeof(ushort ), (obj, _) => Parse<ushort>(obj, ushort.TryParse) },
|
{ typeof(ushort ), (obj, _) => Parse<ushort>(obj, ushort.TryParse) },
|
||||||
{ typeof(uint ), (obj, _) => Parse<uint >(obj, uint .TryParse) },
|
{ typeof(uint ), (obj, _) => Parse<uint >(obj, uint .TryParse) },
|
||||||
{ typeof(int ), ParseInt },
|
{ typeof(int ), ParseInt },
|
||||||
// int - особый случай потому что он может использовать ControlId.Enumerators для прообразования стокового "enum" в значение
|
// int - особый случай потому что он может использовать ControlId.Enumerators для преобразования строкового "enum" в значение
|
||||||
{ typeof(Rectangle), ParseRectangle },
|
{ typeof(Rectangle), ParseRectangle },
|
||||||
{ typeof(Size ), ParseSize },
|
{ typeof(Size ), ParseSize },
|
||||||
{ typeof(Point ), ParsePoint }
|
{ typeof(Point ), ParsePoint }
|
||||||
|
|||||||
@@ -131,9 +131,9 @@ public class BGGR_PISP_COMP1_RAW_FrameDecoder : IFrameDecoder // BGGR_PISP_COMP1
|
|||||||
|
|
||||||
public Mat Decode(int width, int height, int stride, List<byte[]> planes, double rGain, double gGain, double bGain, int blackLevel)
|
public Mat Decode(int width, int height, int stride, List<byte[]> planes, double rGain, double gGain, double bGain, int blackLevel)
|
||||||
{
|
{
|
||||||
// Дектоирование этого формата состоит из двух этапов:
|
// Декодирование этого формата состоит из двух этапов:
|
||||||
// 1) Распаковка исходных данных в которых каждые 8 байт представляют 8 пикселей (это не значит что 1 байт представляет 1 пиксель!)
|
// 1) Распаковка исходных данных в которых каждые 8 байт представляют 8 пикселей (это не значит что 1 байт представляет 1 пиксель!)
|
||||||
// 2) Демозаика полученого Bayer изображения в RGB (BGR)
|
// 2) Демозаика полученного Bayer изображения в RGB (BGR)
|
||||||
|
|
||||||
if (planes.Count < 1)
|
if (planes.Count < 1)
|
||||||
throw new ArgumentException($"At least 1 plane expected, got {planes.Count}");
|
throw new ArgumentException($"At least 1 plane expected, got {planes.Count}");
|
||||||
|
|||||||
+12
-12
@@ -79,23 +79,23 @@ public partial class Program
|
|||||||
Description = "Output image file",
|
Description = "Output image file",
|
||||||
DefaultValueFactory = (_) => new FileInfo("image.png")
|
DefaultValueFactory = (_) => new FileInfo("image.png")
|
||||||
};
|
};
|
||||||
private static readonly Option<double> _captureIntencityWhite = new("--intencity-white")
|
private static readonly Option<double> _captureIntensityWhite = new("--intensity-white")
|
||||||
{
|
{
|
||||||
Description = "Illuminator intencity for white (from 0 to 1)",
|
Description = "Illuminator intensity for white (from 0 to 1)",
|
||||||
DefaultValueFactory = (_) => 1
|
DefaultValueFactory = (_) => 1
|
||||||
};
|
};
|
||||||
private static readonly Option<double> _captureIntencityUv365nm = new("--intencity-uv365nm")
|
private static readonly Option<double> _captureIntensityUv365nm = new("--intensity-uv365nm")
|
||||||
{
|
{
|
||||||
Description = "Illuminator intencity for UV 365 nm (from 0 to 1)",
|
Description = "Illuminator intensity for UV 365 nm (from 0 to 1)",
|
||||||
DefaultValueFactory = (_) => 0
|
DefaultValueFactory = (_) => 0
|
||||||
};
|
};
|
||||||
private static readonly Option<double> _captureIntencityUv254nm = new("--intencity-uv254nm")
|
private static readonly Option<double> _captureIntensityUv254nm = new("--intensity-uv254nm")
|
||||||
{
|
{
|
||||||
Description = "Illuminator intencity for UV 254 nm (from 0 to 1)",
|
Description = "Illuminator intensity for UV 254 nm (from 0 to 1)",
|
||||||
DefaultValueFactory = (_) => 0
|
DefaultValueFactory = (_) => 0
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly Command _imageStorageClearCommand = new("image-storage-clear")
|
private static readonly Command _imageStorageClear = new("image-storage-clear")
|
||||||
{
|
{
|
||||||
Description = "Clear image storage from unused images"
|
Description = "Clear image storage from unused images"
|
||||||
};
|
};
|
||||||
@@ -126,12 +126,12 @@ public partial class Program
|
|||||||
_rootCommand.Add(_captureCommand);
|
_rootCommand.Add(_captureCommand);
|
||||||
_captureCommand.SetAction(Capture);
|
_captureCommand.SetAction(Capture);
|
||||||
_captureCommand.Add(_captureOutputFile);
|
_captureCommand.Add(_captureOutputFile);
|
||||||
_captureCommand.Add(_captureIntencityWhite);
|
_captureCommand.Add(_captureIntensityWhite);
|
||||||
_captureCommand.Add(_captureIntencityUv365nm);
|
_captureCommand.Add(_captureIntensityUv365nm);
|
||||||
_captureCommand.Add(_captureIntencityUv254nm);
|
_captureCommand.Add(_captureIntensityUv254nm);
|
||||||
|
|
||||||
_rootCommand.Add(_imageStorageClearCommand);
|
_rootCommand.Add(_imageStorageClear);
|
||||||
_imageStorageClearCommand.SetAction(ImageStorageClear);
|
_imageStorageClear.SetAction(ImageStorageClear);
|
||||||
|
|
||||||
Console.CancelKeyPress += new ConsoleCancelEventHandler(OnProgramShutdown);
|
Console.CancelKeyPress += new ConsoleCancelEventHandler(OnProgramShutdown);
|
||||||
Console.WriteLine("Press Ctrl+C to shut down.");
|
Console.WriteLine("Press Ctrl+C to shut down.");
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public partial class Program
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Exception occured while image capturing");
|
_logger.LogError(ex, "Exception occurred while image capturing");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ public partial class Program
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Exception occured while image saving");
|
_logger.LogError(ex, "Exception occurred while image saving");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -147,7 +147,7 @@ public partial class Program
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Exception occured while gains computing");
|
_logger.LogError(ex, "Exception occurred while gains computing");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
+17
-17
@@ -21,32 +21,32 @@ public partial class Program
|
|||||||
private readonly CameraService _cameraService;
|
private readonly CameraService _cameraService;
|
||||||
private readonly IlluminatorService _illuminatorService;
|
private readonly IlluminatorService _illuminatorService;
|
||||||
private readonly FileInfo _outputFile;
|
private readonly FileInfo _outputFile;
|
||||||
private readonly double _intencityWhite;
|
private readonly double _intensityWhite;
|
||||||
private readonly double _intencityUv365nm;
|
private readonly double _intensityUv365nm;
|
||||||
private readonly double _intencityUv254nm;
|
private readonly double _intensityUv254nm;
|
||||||
|
|
||||||
public CaptureWorker(ILogger<CaptureWorker> logger, IHostApplicationLifetime applicationLifetime, CameraService cameraService, IlluminatorService illuminatorService, FileInfo outputFile, double intencityWhite, double intencityUv365nm, double intencityUv254nm)
|
public CaptureWorker(ILogger<CaptureWorker> logger, IHostApplicationLifetime applicationLifetime, CameraService cameraService, IlluminatorService illuminatorService, FileInfo outputFile, double intensityWhite, double intensityUv365nm, double intensityUv254nm)
|
||||||
{
|
{
|
||||||
_applicationLifetime = applicationLifetime;
|
_applicationLifetime = applicationLifetime;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_cameraService = cameraService;
|
_cameraService = cameraService;
|
||||||
_illuminatorService = illuminatorService;
|
_illuminatorService = illuminatorService;
|
||||||
_outputFile = outputFile;
|
_outputFile = outputFile;
|
||||||
_intencityWhite = intencityWhite;
|
_intensityWhite = intensityWhite;
|
||||||
_intencityUv365nm = intencityUv365nm;
|
_intensityUv365nm = intensityUv365nm;
|
||||||
_intencityUv254nm = intencityUv254nm;
|
_intensityUv254nm = intensityUv254nm;
|
||||||
|
|
||||||
_logger.LogInformation("Initialized");
|
_logger.LogInformation("Initialized");
|
||||||
_logger.LogInformation("Output File: {}", _outputFile);
|
_logger.LogInformation("Output File: {}", _outputFile);
|
||||||
_logger.LogInformation("Intencity White: {}", _intencityWhite);
|
_logger.LogInformation("Intensity White: {}", _intensityWhite);
|
||||||
_logger.LogInformation("Intencity UV 365 nm: {}", _intencityUv365nm);
|
_logger.LogInformation("Intensity UV 365 nm: {}", _intensityUv365nm);
|
||||||
_logger.LogInformation("Intencity UV 254 nm: {}", _intencityUv254nm);
|
_logger.LogInformation("Intensity UV 254 nm: {}", _intensityUv254nm);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Running camera fine tuning");
|
_logger.LogInformation("Running camera fine tuning");
|
||||||
_illuminatorService.SetIntensity(_intencityWhite, _intencityUv365nm, _intencityUv254nm);
|
_illuminatorService.SetIntensity(_intensityWhite, _intensityUv365nm, _intensityUv254nm);
|
||||||
_illuminatorService.TurnOn();
|
_illuminatorService.TurnOn();
|
||||||
|
|
||||||
Mat? image;
|
Mat? image;
|
||||||
@@ -63,7 +63,7 @@ public partial class Program
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogCritical(ex, "Exception occured while image capturing");
|
_logger.LogCritical(ex, "Exception occurred while image capturing");
|
||||||
_applicationLifetime.StopApplication();
|
_applicationLifetime.StopApplication();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ public partial class Program
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogCritical(ex, "Exception occured while image saving");
|
_logger.LogCritical(ex, "Exception occurred while image saving");
|
||||||
}
|
}
|
||||||
|
|
||||||
_applicationLifetime.StopApplication();
|
_applicationLifetime.StopApplication();
|
||||||
@@ -89,9 +89,9 @@ public partial class Program
|
|||||||
private static void Capture(ParseResult parseResult)
|
private static void Capture(ParseResult parseResult)
|
||||||
{
|
{
|
||||||
var outputFile = parseResult.GetRequiredValue(_captureOutputFile);
|
var outputFile = parseResult.GetRequiredValue(_captureOutputFile);
|
||||||
var intencityWhite = parseResult.GetRequiredValue(_captureIntencityWhite);
|
var intensityWhite = parseResult.GetRequiredValue(_captureIntensityWhite);
|
||||||
var intencityUv365nm = parseResult.GetRequiredValue(_captureIntencityUv365nm);
|
var intensityUv365nm = parseResult.GetRequiredValue(_captureIntensityUv365nm);
|
||||||
var intencityUv254nm = parseResult.GetRequiredValue(_captureIntencityUv254nm);
|
var intensityUv254nm = parseResult.GetRequiredValue(_captureIntensityUv254nm);
|
||||||
|
|
||||||
var builder = Host.CreateApplicationBuilder();
|
var builder = Host.CreateApplicationBuilder();
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ public partial class Program
|
|||||||
var applicationLifetime = services.GetRequiredService<IHostApplicationLifetime>();
|
var applicationLifetime = services.GetRequiredService<IHostApplicationLifetime>();
|
||||||
var cameraService = services.GetRequiredService<CameraService>();
|
var cameraService = services.GetRequiredService<CameraService>();
|
||||||
var illuminatorService = services.GetRequiredService<IlluminatorService>();
|
var illuminatorService = services.GetRequiredService<IlluminatorService>();
|
||||||
return new CaptureWorker(logger, applicationLifetime, cameraService, illuminatorService, outputFile, intencityWhite, intencityUv365nm, intencityUv254nm);
|
return new CaptureWorker(logger, applicationLifetime, cameraService, illuminatorService, outputFile, intensityWhite, intensityUv365nm, intensityUv254nm);
|
||||||
});
|
});
|
||||||
|
|
||||||
var host = builder.Build();
|
var host = builder.Build();
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ namespace GSS2.Test;
|
|||||||
|
|
||||||
public partial class Program
|
public partial class Program
|
||||||
{
|
{
|
||||||
private class ImagesStorateClearWorker : BackgroundService
|
private class ImagesStorageClearWorker : BackgroundService
|
||||||
{
|
{
|
||||||
private readonly ILogger<ImagesStorateClearWorker> _logger;
|
private readonly ILogger<ImagesStorageClearWorker> _logger;
|
||||||
private readonly IHostApplicationLifetime _applicationLifetime;
|
private readonly IHostApplicationLifetime _applicationLifetime;
|
||||||
private readonly AmineContentCalibrationContext _context;
|
private readonly AmineContentCalibrationContext _context;
|
||||||
private readonly ImageStorageService _imageStorageService;
|
private readonly ImageStorageService _imageStorageService;
|
||||||
|
|
||||||
public ImagesStorateClearWorker(ILogger<ImagesStorateClearWorker> logger, IHostApplicationLifetime applicationLifetime, AmineContentCalibrationContext context, ImageStorageService imageStorageService)
|
public ImagesStorageClearWorker(ILogger<ImagesStorageClearWorker> logger, IHostApplicationLifetime applicationLifetime, AmineContentCalibrationContext context, ImageStorageService imageStorageService)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_applicationLifetime = applicationLifetime;
|
_applicationLifetime = applicationLifetime;
|
||||||
@@ -85,7 +85,7 @@ public partial class Program
|
|||||||
builder.Services.AddAmineContentCalibrationContext(builder.Configuration);
|
builder.Services.AddAmineContentCalibrationContext(builder.Configuration);
|
||||||
builder.Services.AddImageStorageService(new DirectoryInfo("images"));
|
builder.Services.AddImageStorageService(new DirectoryInfo("images"));
|
||||||
|
|
||||||
builder.Services.AddHostedService<ImagesStorateClearWorker>();
|
builder.Services.AddHostedService<ImagesStorageClearWorker>();
|
||||||
|
|
||||||
var host = builder.Build();
|
var host = builder.Build();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
|
||||||
namespace GSS2.Core.Extentions;
|
namespace GSS2.Core.UI.Extensions;
|
||||||
|
|
||||||
public static class PointHelper
|
public static class PointHelper
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using Avalonia.Media;
|
|||||||
using Avalonia.Styling;
|
using Avalonia.Styling;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
|
||||||
using GSS2.Core.Extentions;
|
using GSS2.Core.Extensions;
|
||||||
|
|
||||||
namespace GSS2.UI.Core;
|
namespace GSS2.UI.Core;
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class SectionPanel : Panel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private readonly Dictionary<Control, int> _childIndeces = new Dictionary<Control, int>();
|
private readonly Dictionary<Control, int> _childIndices = new Dictionary<Control, int>();
|
||||||
private bool _initialized = false;
|
private bool _initialized = false;
|
||||||
private int _previousIndex = 0;
|
private int _previousIndex = 0;
|
||||||
|
|
||||||
@@ -135,9 +135,9 @@ public class SectionPanel : Panel
|
|||||||
|
|
||||||
if (_initialized)
|
if (_initialized)
|
||||||
{
|
{
|
||||||
_childIndeces.Clear();
|
_childIndices.Clear();
|
||||||
foreach (var (i, child) in Children.Enumerate())
|
foreach (var (i, child) in Children.Enumerate())
|
||||||
_childIndeces.Add(child, i);
|
_childIndices.Add(child, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panel.InvalidateArrange();
|
panel.InvalidateArrange();
|
||||||
@@ -272,7 +272,7 @@ public class SectionPanel : Panel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var (child, i) in _childIndeces)
|
foreach (var (child, i) in _childIndices)
|
||||||
{
|
{
|
||||||
var transform = child.RenderTransform as TranslateTransform;
|
var transform = child.RenderTransform as TranslateTransform;
|
||||||
if (transform is null)
|
if (transform is null)
|
||||||
@@ -303,13 +303,13 @@ public class SectionPanel : Panel
|
|||||||
if (!_initialized)
|
if (!_initialized)
|
||||||
{
|
{
|
||||||
foreach (var (i, child) in Children.Enumerate())
|
foreach (var (i, child) in Children.Enumerate())
|
||||||
_childIndeces.Add(child, i);
|
_childIndices.Add(child, i);
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_previousIndex == CurrentIndex)
|
if (_previousIndex == CurrentIndex)
|
||||||
{
|
{
|
||||||
foreach (var (child, i) in _childIndeces)
|
foreach (var (child, i) in _childIndices)
|
||||||
{
|
{
|
||||||
var rect = Orientation switch
|
var rect = Orientation switch
|
||||||
{
|
{
|
||||||
@@ -334,27 +334,27 @@ public class SectionPanel : Panel
|
|||||||
{
|
{
|
||||||
int indexSingleShift = indexShift / Math.Abs(indexShift);
|
int indexSingleShift = indexShift / Math.Abs(indexShift);
|
||||||
|
|
||||||
var firstIndex = _childIndeces.Min(ch => ch.Value);
|
var firstIndex = _childIndices.Min(ch => ch.Value);
|
||||||
var lastIndex = _childIndeces.Max(ch => ch.Value);
|
var lastIndex = _childIndices.Max(ch => ch.Value);
|
||||||
|
|
||||||
if (indexSingleShift == -1 &&
|
if (indexSingleShift == -1 &&
|
||||||
_previousIndex - 1 < firstIndex)
|
_previousIndex - 1 < firstIndex)
|
||||||
{
|
{
|
||||||
var newIndex = firstIndex - 1;
|
var newIndex = firstIndex - 1;
|
||||||
var (child, _) = _childIndeces.MaxBy(ch => ch.Value);
|
var (child, _) = _childIndices.MaxBy(ch => ch.Value);
|
||||||
InstantTransform(child, -Children.Count(), size);
|
InstantTransform(child, -Children.Count(), size);
|
||||||
|
|
||||||
_childIndeces[child] = newIndex;
|
_childIndices[child] = newIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexSingleShift == 1 &&
|
if (indexSingleShift == 1 &&
|
||||||
_previousIndex + 1 > lastIndex)
|
_previousIndex + 1 > lastIndex)
|
||||||
{
|
{
|
||||||
var newIndex = lastIndex + 1;
|
var newIndex = lastIndex + 1;
|
||||||
var (child, _) = _childIndeces.MinBy(ch => ch.Value);
|
var (child, _) = _childIndices.MinBy(ch => ch.Value);
|
||||||
InstantTransform(child, Children.Count(), size);
|
InstantTransform(child, Children.Count(), size);
|
||||||
|
|
||||||
_childIndeces[child] = newIndex;
|
_childIndices[child] = newIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Task> animations = new List<Task>();
|
List<Task> animations = new List<Task>();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using Avalonia.Media.Imaging;
|
|||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
|
||||||
using GSS2.Core.Hardware;
|
using GSS2.Core.Hardware;
|
||||||
using GSS2.Core.Extentions;
|
using GSS2.Core.Extensions;
|
||||||
using GSS2.Core.Analysis.AmineContent.Database.Calibration;
|
using GSS2.Core.Analysis.AmineContent.Database.Calibration;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ public partial class AmineContentSeparatorCalibrationViewModel : ViewModelBase
|
|||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand] private void CencelImageCapturing() => _captureImagesTaskCts?.Cancel();
|
[RelayCommand] private void CancelImageCapturing() => _captureImagesTaskCts?.Cancel();
|
||||||
[RelayCommand] private void ImagesSectionPrevious() => ImagesSectionCurrentIndex--;
|
[RelayCommand] private void ImagesSectionPrevious() => ImagesSectionCurrentIndex--;
|
||||||
[RelayCommand] private void ImagesSectionNext() => ImagesSectionCurrentIndex++;
|
[RelayCommand] private void ImagesSectionNext() => ImagesSectionCurrentIndex++;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public partial class CameraViewModel : ViewModelBase, IDisposable
|
|||||||
private readonly CameraService _cameraService;
|
private readonly CameraService _cameraService;
|
||||||
private readonly System.Timers.Timer _renderTimer;
|
private readonly System.Timers.Timer _renderTimer;
|
||||||
|
|
||||||
public event EventHandler? RenderReqested;
|
public event EventHandler? RenderRequested;
|
||||||
|
|
||||||
[ObservableProperty] private Color _background = Colors.Transparent;
|
[ObservableProperty] private Color _background = Colors.Transparent;
|
||||||
[ObservableProperty] private Stretch _stretchMode = Stretch.Uniform;
|
[ObservableProperty] private Stretch _stretchMode = Stretch.Uniform;
|
||||||
@@ -34,7 +34,7 @@ public partial class CameraViewModel : ViewModelBase, IDisposable
|
|||||||
_renderTimer.Elapsed += (_, _) =>
|
_renderTimer.Elapsed += (_, _) =>
|
||||||
{
|
{
|
||||||
if (!_cameraService.IsImageCapturing)
|
if (!_cameraService.IsImageCapturing)
|
||||||
RenderReqested?.Invoke(this, new EventArgs());
|
RenderRequested?.Invoke(this, new EventArgs());
|
||||||
};
|
};
|
||||||
|
|
||||||
_logger.LogInformation("Initialized");
|
_logger.LogInformation("Initialized");
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ public partial class IlluminatorControllerViewModel : ViewModelBase
|
|||||||
private readonly ILogger<IlluminatorControllerViewModel> _logger;
|
private readonly ILogger<IlluminatorControllerViewModel> _logger;
|
||||||
private readonly IlluminatorService _illuminatorService;
|
private readonly IlluminatorService _illuminatorService;
|
||||||
|
|
||||||
private bool _whiteIntencityChanging = false;
|
private bool _whiteIntensityChanging = false;
|
||||||
private bool _uv365IntencityChanging = false;
|
private bool _uv365IntensityChanging = false;
|
||||||
private bool _uv254IntencityChanging = false;
|
private bool _uv254IntensityChanging = false;
|
||||||
|
|
||||||
[ObservableProperty] private double _whiteIntencity;
|
[ObservableProperty] private double _whiteIntensity;
|
||||||
[ObservableProperty] private double _uv365Intencity;
|
[ObservableProperty] private double _uv365Intensity;
|
||||||
[ObservableProperty] private double _uv254Intencity;
|
[ObservableProperty] private double _uv254Intensity;
|
||||||
[ObservableProperty] private bool _enabled;
|
[ObservableProperty] private bool _enabled;
|
||||||
[ObservableProperty] Orientation _orientation;
|
[ObservableProperty] Orientation _orientation;
|
||||||
|
|
||||||
@@ -30,38 +30,38 @@ public partial class IlluminatorControllerViewModel : ViewModelBase
|
|||||||
|
|
||||||
_illuminatorService = illuminatorService;
|
_illuminatorService = illuminatorService;
|
||||||
|
|
||||||
WhiteIntencity = 0;
|
WhiteIntensity = 0;
|
||||||
Uv365Intencity = 0;
|
Uv365Intensity = 0;
|
||||||
Uv254Intencity = 0;
|
Uv254Intensity = 0;
|
||||||
Orientation = Orientation.Horizontal;
|
Orientation = Orientation.Horizontal;
|
||||||
Enabled = false;
|
Enabled = false;
|
||||||
|
|
||||||
_logger.LogInformation("Initialized");
|
_logger.LogInformation("Initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnWhiteIntencityChanged(double value)
|
partial void OnWhiteIntensityChanged(double value)
|
||||||
{
|
{
|
||||||
if (_whiteIntencityChanging)
|
if (_whiteIntensityChanging)
|
||||||
return;
|
return;
|
||||||
_whiteIntencityChanging = true;
|
_whiteIntensityChanging = true;
|
||||||
_illuminatorService.SetIntensity(white: value);
|
_illuminatorService.SetIntensity(white: value);
|
||||||
_whiteIntencityChanging = false;
|
_whiteIntensityChanging = false;
|
||||||
}
|
}
|
||||||
partial void OnUv365IntencityChanged(double value)
|
partial void OnUv365IntensityChanged(double value)
|
||||||
{
|
{
|
||||||
if (_uv365IntencityChanging)
|
if (_uv365IntensityChanging)
|
||||||
return;
|
return;
|
||||||
_uv365IntencityChanging = true;
|
_uv365IntensityChanging = true;
|
||||||
_illuminatorService.SetIntensity(uv365: value);
|
_illuminatorService.SetIntensity(uv365: value);
|
||||||
_uv365IntencityChanging = false;
|
_uv365IntensityChanging = false;
|
||||||
}
|
}
|
||||||
partial void OnUv254IntencityChanged(double value)
|
partial void OnUv254IntensityChanged(double value)
|
||||||
{
|
{
|
||||||
if (_uv254IntencityChanging)
|
if (_uv254IntensityChanging)
|
||||||
return;
|
return;
|
||||||
_uv254IntencityChanging = true;
|
_uv254IntensityChanging = true;
|
||||||
_illuminatorService.SetIntensity(uv254: value);
|
_illuminatorService.SetIntensity(uv254: value);
|
||||||
_uv254IntencityChanging = false;
|
_uv254IntensityChanging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnEnabledChanged(bool value)
|
partial void OnEnabledChanged(bool value)
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public partial class ResourcesViewModel : ViewModelBase, IDisposable
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ResourceBarViewModel CreateBarViewModel(ILogger<ResourceBarViewModel> logger, Func<LiveChartsCore.Kernel.ChartPoint<ObservableValue, LiveChartsCore.SkiaSharpView.Drawing.Geometries.DoughnutGeometry, LiveChartsCore.SkiaSharpView.Drawing.Geometries.LabelGeometry>, string> formater)
|
ResourceBarViewModel CreateBarViewModel(ILogger<ResourceBarViewModel> logger, Func<LiveChartsCore.Kernel.ChartPoint<ObservableValue, LiveChartsCore.SkiaSharpView.Drawing.Geometries.DoughnutGeometry, LiveChartsCore.SkiaSharpView.Drawing.Geometries.LabelGeometry>, string> formatter)
|
||||||
{
|
{
|
||||||
return new ResourceBarViewModel(
|
return new ResourceBarViewModel(
|
||||||
logger: logger,
|
logger: logger,
|
||||||
@@ -111,7 +111,7 @@ public partial class ResourcesViewModel : ViewModelBase, IDisposable
|
|||||||
ShowDataLabels = true,
|
ShowDataLabels = true,
|
||||||
IsHoverable = false,
|
IsHoverable = false,
|
||||||
HoverPushout = 0,
|
HoverPushout = 0,
|
||||||
DataLabelsFormatter = formater,
|
DataLabelsFormatter = formatter,
|
||||||
DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.ChartCenter,
|
DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.ChartCenter,
|
||||||
DataLabelsPaint = new SolidColorPaint(SKColors.White)
|
DataLabelsPaint = new SolidColorPaint(SKColors.White)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -187,7 +187,7 @@
|
|||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Изображениямя -->
|
<!-- Изображения -->
|
||||||
<Grid ColumnSpacing="5" RowSpacing="5">
|
<Grid ColumnSpacing="5" RowSpacing="5">
|
||||||
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@@ -435,7 +435,7 @@
|
|||||||
<Button
|
<Button
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Command="{Binding CencelImageCapturingCommand}"
|
Command="{Binding CancelImageCapturingCommand}"
|
||||||
Content="Отменить съёмку"
|
Content="Отменить съёмку"
|
||||||
IsVisible="{Binding CaptureImagesTask, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
IsVisible="{Binding CaptureImagesTask, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||||
|
|
||||||
@@ -443,7 +443,7 @@
|
|||||||
|
|
||||||
</core:SectionPanel>
|
</core:SectionPanel>
|
||||||
|
|
||||||
<!-- Общие конпки гланой панели -->
|
<!-- Общие кнопки главной панели -->
|
||||||
<Button
|
<Button
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using Avalonia.Input;
|
|||||||
|
|
||||||
using GSS2.UI.Core.ViewModels;
|
using GSS2.UI.Core.ViewModels;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using GSS2.Core.Extentions;
|
using GSS2.Core.UI.Extensions;
|
||||||
|
|
||||||
namespace GSS2.UI.Core.Views;
|
namespace GSS2.UI.Core.Views;
|
||||||
|
|
||||||
@@ -40,9 +40,9 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
public const int EGL_DMA_BUF_PLANE0_OFFSET_EXT = 0x3273;
|
public const int EGL_DMA_BUF_PLANE0_OFFSET_EXT = 0x3273;
|
||||||
public const int EGL_DMA_BUF_PLANE0_PITCH_EXT = 0x3274;
|
public const int EGL_DMA_BUF_PLANE0_PITCH_EXT = 0x3274;
|
||||||
|
|
||||||
public delegate IntPtr GlEGLImageTargetTexture2DOESDeligate(int target, IntPtr image);
|
public delegate IntPtr GlEGLImageTargetTexture2DOESDelegate(int target, IntPtr image);
|
||||||
public delegate IntPtr EglCreateImageKHRDeligate(IntPtr dpy, IntPtr ctx, int target, IntPtr buffer, int[] attribs);
|
public delegate IntPtr EglCreateImageKHRDelegate(IntPtr dpy, IntPtr ctx, int target, IntPtr buffer, int[] attribs);
|
||||||
public delegate bool EglDestroyImageKHRDeligate(IntPtr dpy, IntPtr image);
|
public delegate bool EglDestroyImageKHRDelegate(IntPtr dpy, IntPtr image);
|
||||||
|
|
||||||
private const string VERTEX_SHADER = @"
|
private const string VERTEX_SHADER = @"
|
||||||
#version 300 es
|
#version 300 es
|
||||||
@@ -91,19 +91,19 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
public int UUvLocation { get; }
|
public int UUvLocation { get; }
|
||||||
public int VAO { get; }
|
public int VAO { get; }
|
||||||
public int VBO { get; }
|
public int VBO { get; }
|
||||||
public EglCreateImageKHRDeligate EglCreateImageKHR { get; }
|
public EglCreateImageKHRDelegate EglCreateImageKHR { get; }
|
||||||
public EglDestroyImageKHRDeligate EglDestroyImageKHR { get; }
|
public EglDestroyImageKHRDelegate EglDestroyImageKHR { get; }
|
||||||
public GlEGLImageTargetTexture2DOESDeligate GlEGLImageTargetTexture2DOES { get; }
|
public GlEGLImageTargetTexture2DOESDelegate GlEGLImageTargetTexture2DOES { get; }
|
||||||
|
|
||||||
public OpenGLContext(GlInterface gl)
|
public OpenGLContext(GlInterface gl)
|
||||||
{
|
{
|
||||||
var glExtensions = gl.GetString(GlConsts.GL_EXTENSIONS);
|
var glExtensions = gl.GetString(GlConsts.GL_EXTENSIONS);
|
||||||
if (glExtensions is null)
|
if (glExtensions is null)
|
||||||
throw new Exception("GL extentions query returned null string");
|
throw new Exception("GL extensions query returned null string");
|
||||||
|
|
||||||
if (!glExtensions.Contains("GL_OES_EGL_image") &&
|
if (!glExtensions.Contains("GL_OES_EGL_image") &&
|
||||||
!glExtensions.Contains("GL_OES_EGL_image_external"))
|
!glExtensions.Contains("GL_OES_EGL_image_external"))
|
||||||
throw new Exception("Required GL extentions \"GL_OES_EGL_image_external\" or \"GL_OES_EGL_image\" not found");
|
throw new Exception("Required GL extensions \"GL_OES_EGL_image_external\" or \"GL_OES_EGL_image\" not found");
|
||||||
|
|
||||||
EglDisplay = eglGetCurrentDisplay();
|
EglDisplay = eglGetCurrentDisplay();
|
||||||
if (EglDisplay == IntPtr.Zero)
|
if (EglDisplay == IntPtr.Zero)
|
||||||
@@ -111,25 +111,25 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
|
|
||||||
var eglExtensions = Marshal.PtrToStringAnsi(eglQueryString(EglDisplay, EglConsts.EGL_EXTENSIONS));
|
var eglExtensions = Marshal.PtrToStringAnsi(eglQueryString(EglDisplay, EglConsts.EGL_EXTENSIONS));
|
||||||
if (eglExtensions is null)
|
if (eglExtensions is null)
|
||||||
throw new Exception("EGL extentions query returned null");
|
throw new Exception("EGL extensions query returned null");
|
||||||
|
|
||||||
if (!eglExtensions.Contains("EGL_EXT_image_dma_buf_import"))
|
if (!eglExtensions.Contains("EGL_EXT_image_dma_buf_import"))
|
||||||
throw new Exception("Required EGL extention \"EGL_EXT_image_dma_buf_import\" not found");
|
throw new Exception("Required EGL extension \"EGL_EXT_image_dma_buf_import\" not found");
|
||||||
|
|
||||||
var pEglCreateImageKHR = eglGetProcAddress("eglCreateImageKHR");
|
var pEglCreateImageKHR = eglGetProcAddress("eglCreateImageKHR");
|
||||||
if (pEglCreateImageKHR == IntPtr.Zero)
|
if (pEglCreateImageKHR == IntPtr.Zero)
|
||||||
throw new Exception("Required EGL method \"eglCreateImageKHR\" not found");
|
throw new Exception("Required EGL method \"eglCreateImageKHR\" not found");
|
||||||
EglCreateImageKHR = Marshal.GetDelegateForFunctionPointer<EglCreateImageKHRDeligate>(pEglCreateImageKHR);
|
EglCreateImageKHR = Marshal.GetDelegateForFunctionPointer<EglCreateImageKHRDelegate>(pEglCreateImageKHR);
|
||||||
|
|
||||||
var pEglDestroyImageKHR = eglGetProcAddress("eglDestroyImageKHR");
|
var pEglDestroyImageKHR = eglGetProcAddress("eglDestroyImageKHR");
|
||||||
if (pEglDestroyImageKHR == IntPtr.Zero)
|
if (pEglDestroyImageKHR == IntPtr.Zero)
|
||||||
throw new Exception("Required EGL method \"eglDestroyImageKHR\" not found");
|
throw new Exception("Required EGL method \"eglDestroyImageKHR\" not found");
|
||||||
EglDestroyImageKHR = Marshal.GetDelegateForFunctionPointer<EglDestroyImageKHRDeligate>(pEglDestroyImageKHR);
|
EglDestroyImageKHR = Marshal.GetDelegateForFunctionPointer<EglDestroyImageKHRDelegate>(pEglDestroyImageKHR);
|
||||||
|
|
||||||
var pGlEGLImageTargetTexture2DOES = eglGetProcAddress("glEGLImageTargetTexture2DOES");
|
var pGlEGLImageTargetTexture2DOES = eglGetProcAddress("glEGLImageTargetTexture2DOES");
|
||||||
if (pGlEGLImageTargetTexture2DOES == IntPtr.Zero)
|
if (pGlEGLImageTargetTexture2DOES == IntPtr.Zero)
|
||||||
throw new Exception("Required EGL method \"glEGLImageTargetTexture2DOES\" not found");
|
throw new Exception("Required EGL method \"glEGLImageTargetTexture2DOES\" not found");
|
||||||
GlEGLImageTargetTexture2DOES = Marshal.GetDelegateForFunctionPointer<GlEGLImageTargetTexture2DOESDeligate>(pGlEGLImageTargetTexture2DOES);
|
GlEGLImageTargetTexture2DOES = Marshal.GetDelegateForFunctionPointer<GlEGLImageTargetTexture2DOESDelegate>(pGlEGLImageTargetTexture2DOES);
|
||||||
|
|
||||||
Texture = gl.GenTexture(); ThrowIfOpenGLError(gl);
|
Texture = gl.GenTexture(); ThrowIfOpenGLError(gl);
|
||||||
gl.BindTexture(GlConsts.GL_TEXTURE_2D, Texture); ThrowIfOpenGLError(gl);
|
gl.BindTexture(GlConsts.GL_TEXTURE_2D, Texture); ThrowIfOpenGLError(gl);
|
||||||
@@ -189,7 +189,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly ILogger<CameraView> _logger;
|
private readonly ILogger<CameraView> _logger;
|
||||||
private readonly Dictionary<int, IntPtr> _importedDmaBufers = new Dictionary<int, nint>();
|
private readonly Dictionary<int, IntPtr> _importedDmaBuffers = new Dictionary<int, nint>();
|
||||||
private bool _isViewFinderStarted = false;
|
private bool _isViewFinderStarted = false;
|
||||||
private OpenGLContext? _openGLContext = null;
|
private OpenGLContext? _openGLContext = null;
|
||||||
private Point? _lastMousePosition = null;
|
private Point? _lastMousePosition = null;
|
||||||
@@ -238,7 +238,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
viewModel.StartViewFinder();
|
viewModel.StartViewFinder();
|
||||||
viewModel.RenderReqested += RenderReqested;
|
viewModel.RenderRequested += RenderRequested;
|
||||||
_isViewFinderStarted = true;
|
_isViewFinderStarted = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -257,7 +257,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
viewModel.StopViewFinder();
|
viewModel.StopViewFinder();
|
||||||
foreach (var (fd, image) in _importedDmaBufers)
|
foreach (var (fd, image) in _importedDmaBuffers)
|
||||||
_openGLContext?.EglDestroyImageKHR!(_openGLContext.EglDisplay, image);
|
_openGLContext?.EglDestroyImageKHR!(_openGLContext.EglDisplay, image);
|
||||||
_isViewFinderStarted = false;
|
_isViewFinderStarted = false;
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
{
|
{
|
||||||
_logger.LogCritical(ex, "Exception while view finder stop");
|
_logger.LogCritical(ex, "Exception while view finder stop");
|
||||||
}
|
}
|
||||||
viewModel.RenderReqested -= RenderReqested;
|
viewModel.RenderRequested -= RenderRequested;
|
||||||
}
|
}
|
||||||
else if (_isViewFinderStarted)
|
else if (_isViewFinderStarted)
|
||||||
_logger.LogCritical("Cannot stop view finder, data context is null or not camera view model");
|
_logger.LogCritical("Cannot stop view finder, data context is null or not camera view model");
|
||||||
@@ -282,7 +282,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
|
|
||||||
// Рассчитываем позицию в координатах изображения (до масштабирования)
|
// Рассчитываем позицию в координатах изображения (до масштабирования)
|
||||||
var imageX = (position.X - Bounds.Width / 2 - _panX) / _zoom;
|
var imageX = (position.X - Bounds.Width / 2 - _panX) / _zoom;
|
||||||
var imageY = (-position.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертированна
|
var imageY = (-position.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертирована
|
||||||
|
|
||||||
// Применяем масштаб
|
// Применяем масштаб
|
||||||
float zoomFactor = ea.Delta.Y > 0 ? 1.1f : 1 / 1.1f;
|
float zoomFactor = ea.Delta.Y > 0 ? 1.1f : 1 / 1.1f;
|
||||||
@@ -294,7 +294,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
{
|
{
|
||||||
// Пересчитываем смещение так, чтобы указатель остался на месте
|
// Пересчитываем смещение так, чтобы указатель остался на месте
|
||||||
_panX = (float)(position.X - Bounds.Width / 2 - imageX * _zoom);
|
_panX = (float)(position.X - Bounds.Width / 2 - imageX * _zoom);
|
||||||
_panY = (float)(-position.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертированна
|
_panY = (float)(-position.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертирована
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -358,7 +358,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
}
|
}
|
||||||
var position = ea.GetPosition(this);
|
var position = ea.GetPosition(this);
|
||||||
_panX -= (float)(_lastMousePosition.Value.X - position.X);
|
_panX -= (float)(_lastMousePosition.Value.X - position.X);
|
||||||
_panY += (float)(_lastMousePosition.Value.Y - position.Y); // Ось Y инвертированна
|
_panY += (float)(_lastMousePosition.Value.Y - position.Y); // Ось Y инвертирована
|
||||||
_lastMousePosition = position;
|
_lastMousePosition = position;
|
||||||
}
|
}
|
||||||
else if (ea.Pointer.Type == PointerType.Touch)
|
else if (ea.Pointer.Type == PointerType.Touch)
|
||||||
@@ -376,11 +376,11 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lastTouchPositions.Count() == 1 && _zoom != 1) // Если есть только одно прикосновение и зум != 1, то токлько перемещение
|
if (_lastTouchPositions.Count() == 1 && _zoom != 1) // Если есть только одно прикосновение и зум != 1, то только перемещение
|
||||||
{
|
{
|
||||||
var position = ea.GetPosition(this);
|
var position = ea.GetPosition(this);
|
||||||
_panX -= (float)(_lastTouchPositions[ea.Pointer.Id].X - position.X);
|
_panX -= (float)(_lastTouchPositions[ea.Pointer.Id].X - position.X);
|
||||||
_panY += (float)(_lastTouchPositions[ea.Pointer.Id].Y - position.Y); // Ось Y инвертированна
|
_panY += (float)(_lastTouchPositions[ea.Pointer.Id].Y - position.Y); // Ось Y инвертирована
|
||||||
_lastTouchPositions[ea.Pointer.Id] = position;
|
_lastTouchPositions[ea.Pointer.Id] = position;
|
||||||
}
|
}
|
||||||
else if (_lastTouchPositions.Count() == 2) // Если два прикосновения, то перемещение с приближением
|
else if (_lastTouchPositions.Count() == 2) // Если два прикосновения, то перемещение с приближением
|
||||||
@@ -402,14 +402,14 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
newZoom = (float)Math.Clamp(newZoom, 1f, 10f);
|
newZoom = (float)Math.Clamp(newZoom, 1f, 10f);
|
||||||
|
|
||||||
var imageX = (newCenter.X - Bounds.Width / 2 - _panX) / _zoom;
|
var imageX = (newCenter.X - Bounds.Width / 2 - _panX) / _zoom;
|
||||||
var imageY = (-newCenter.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертированна
|
var imageY = (-newCenter.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертирована
|
||||||
|
|
||||||
_zoom = newZoom;
|
_zoom = newZoom;
|
||||||
|
|
||||||
if (_zoom > 1f)
|
if (_zoom > 1f)
|
||||||
{
|
{
|
||||||
_panX = (float)(newCenter.X - Bounds.Width / 2 - imageX * _zoom);
|
_panX = (float)(newCenter.X - Bounds.Width / 2 - imageX * _zoom);
|
||||||
_panY = (float)(-newCenter.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертированна
|
_panY = (float)(-newCenter.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертирована
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -427,7 +427,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
context.FillRectangle(new SolidColorBrush(Background), new Rect(0, 0, Bounds.Width, Bounds.Height));
|
context.FillRectangle(new SolidColorBrush(Background), new Rect(0, 0, Bounds.Width, Bounds.Height));
|
||||||
base.Render(context);
|
base.Render(context);
|
||||||
}
|
}
|
||||||
private void RenderReqested(object? sender, EventArgs ea) => Dispatcher.UIThread.Invoke(() => RequestNextFrameRendering());
|
private void RenderRequested(object? sender, EventArgs ea) => Dispatcher.UIThread.Invoke(() => RequestNextFrameRendering());
|
||||||
|
|
||||||
protected override void OnOpenGlInit(GlInterface gl)
|
protected override void OnOpenGlInit(GlInterface gl)
|
||||||
{
|
{
|
||||||
@@ -463,36 +463,36 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
return;
|
return;
|
||||||
var (frameBuffer, streamConfiguration) = frame.Value;
|
var (frameBuffer, streamConfiguration) = frame.Value;
|
||||||
|
|
||||||
// 0. Проверяем что полученый фрейм ожидаемый праильный формат
|
// 0. Проверяем что полученный фрейм ожидаемый правильный формат
|
||||||
var width = streamConfiguration.Size.Width;
|
var width = streamConfiguration.Size.Width;
|
||||||
if (width <= 0)
|
if (width <= 0)
|
||||||
{
|
{
|
||||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected frame width >= 0, got {}", streamConfiguration.Size.Width);
|
_logger.LogError("Cannot render frame, stream configuration validation error, expected frame width >= 0, got {}", streamConfiguration.Size.Width);
|
||||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var height = streamConfiguration.Size.Height;
|
var height = streamConfiguration.Size.Height;
|
||||||
if (height <= 0)
|
if (height <= 0)
|
||||||
{
|
{
|
||||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected frame height >= 0, got {}", streamConfiguration.Size.Height);
|
_logger.LogError("Cannot render frame, stream configuration validation error, expected frame height >= 0, got {}", streamConfiguration.Size.Height);
|
||||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (streamConfiguration.PixelFormat.Fourcc != OpenGLContext.DRM_FORMAT_BGRX8888)
|
if (streamConfiguration.PixelFormat.Fourcc != OpenGLContext.DRM_FORMAT_BGRX8888)
|
||||||
{
|
{
|
||||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected forcc: 0x{:X}, got 0x{:X}", OpenGLContext.DRM_FORMAT_BGRX8888, streamConfiguration.PixelFormat.Fourcc);
|
_logger.LogError("Cannot render frame, stream configuration validation error, expected fourcc: 0x{:X}, got 0x{:X}", OpenGLContext.DRM_FORMAT_BGRX8888, streamConfiguration.PixelFormat.Fourcc);
|
||||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (streamConfiguration.PixelFormat.Modifier != 0)
|
if (streamConfiguration.PixelFormat.Modifier != 0)
|
||||||
{
|
{
|
||||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected DRM modifier: 0x{:X}, got 0x{:X}", 0, streamConfiguration.PixelFormat.Modifier);
|
_logger.LogError("Cannot render frame, stream configuration validation error, expected DRM modifier: 0x{:X}, got 0x{:X}", 0, streamConfiguration.PixelFormat.Modifier);
|
||||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (frameBuffer.Planes.Count() != 1)
|
if (frameBuffer.Planes.Count() != 1)
|
||||||
{
|
{
|
||||||
_logger.LogError("Cannot render frame, planes vaildation error, expected planes count: 0, got {}", frameBuffer.Planes.Count());
|
_logger.LogError("Cannot render frame, planes validation error, expected planes count: 0, got {}", frameBuffer.Planes.Count());
|
||||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -506,7 +506,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
var fd = plane.Fd.Get();
|
var fd = plane.Fd.Get();
|
||||||
if (fd <= 0)
|
if (fd <= 0)
|
||||||
{
|
{
|
||||||
_logger.LogError("Cannot render frame, FD vaildation error, FD >= 0, got 0x{:X}", fd);
|
_logger.LogError("Cannot render frame, FD validation error, FD >= 0, got 0x{:X}", fd);
|
||||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -521,10 +521,10 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
|
|
||||||
// 2. Создаём EGL изображение из dma-buf
|
// 2. Создаём EGL изображение из dma-buf
|
||||||
IntPtr image;
|
IntPtr image;
|
||||||
if (_importedDmaBufers.ContainsKey(fd))
|
if (_importedDmaBuffers.ContainsKey(fd))
|
||||||
{
|
{
|
||||||
// 2.1. Если EGL изображение для fd уже создано, то берём его из словаря
|
// 2.1. Если EGL изображение для fd уже создано, то берём его из словаря
|
||||||
image = _importedDmaBufers[fd];
|
image = _importedDmaBuffers[fd];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -540,7 +540,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
EglConsts.EGL_NONE
|
EglConsts.EGL_NONE
|
||||||
};
|
};
|
||||||
image = _openGLContext.EglCreateImageKHR.Invoke(_openGLContext.EglDisplay, IntPtr.Zero, OpenGLContext.EGL_LINUX_DMA_BUF_EXT, IntPtr.Zero, attribs);
|
image = _openGLContext.EglCreateImageKHR.Invoke(_openGLContext.EglDisplay, IntPtr.Zero, OpenGLContext.EGL_LINUX_DMA_BUF_EXT, IntPtr.Zero, attribs);
|
||||||
_importedDmaBufers.Add(fd, image);
|
_importedDmaBuffers.Add(fd, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Биндим текстуры текстуры
|
// 3. Биндим текстуры текстуры
|
||||||
@@ -550,7 +550,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
// 4. Привязываем EGL изображение к текстуре
|
// 4. Привязываем EGL изображение к текстуре
|
||||||
_openGLContext.GlEGLImageTargetTexture2DOES!(GlConsts.GL_TEXTURE_2D, image);
|
_openGLContext.GlEGLImageTargetTexture2DOES!(GlConsts.GL_TEXTURE_2D, image);
|
||||||
|
|
||||||
// 5. Вычисляем матрицы транформаций
|
// 5. Вычисляем матрицы трансформаций
|
||||||
var mvp = ComputeMvp(stretchMode, width, height);
|
var mvp = ComputeMvp(stretchMode, width, height);
|
||||||
var zoom = Matrix4x4.CreateScale(_zoom, _zoom, 1f);
|
var zoom = Matrix4x4.CreateScale(_zoom, _zoom, 1f);
|
||||||
var translate = Matrix4x4.CreateTranslation((float)(_panX / Bounds.Width * 2), (float)(_panY / Bounds.Height * 2), 0);
|
var translate = Matrix4x4.CreateTranslation((float)(_panX / Bounds.Width * 2), (float)(_panY / Bounds.Height * 2), 0);
|
||||||
@@ -597,7 +597,7 @@ public partial class CameraView : OpenGlControlBase
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Exception whiel OpenGL render");
|
_logger.LogError(ex, "Exception while OpenGL render");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private Matrix4x4 ComputeMvp(Stretch stretch, float imageWidth, float imageHeight)
|
private Matrix4x4 ComputeMvp(Stretch stretch, float imageWidth, float imageHeight)
|
||||||
|
|||||||
@@ -42,9 +42,9 @@
|
|||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
Spacing="20">
|
Spacing="20">
|
||||||
|
|
||||||
<Slider Classes="horizontal" Value="{Binding WhiteIntencity}" />
|
<Slider Classes="horizontal" Value="{Binding WhiteIntensity}" />
|
||||||
<Slider Classes="horizontal" Value="{Binding Uv365Intencity}" />
|
<Slider Classes="horizontal" Value="{Binding Uv365Intensity}" />
|
||||||
<Slider Classes="horizontal" Value="{Binding Uv254Intencity}" />
|
<Slider Classes="horizontal" Value="{Binding Uv254Intensity}" />
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
@@ -71,9 +71,9 @@
|
|||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
Spacing="20">
|
Spacing="20">
|
||||||
|
|
||||||
<Slider Classes="vertical" Value="{Binding WhiteIntencity}" />
|
<Slider Classes="vertical" Value="{Binding WhiteIntensity}" />
|
||||||
<Slider Classes="vertical" Value="{Binding Uv365Intencity}" />
|
<Slider Classes="vertical" Value="{Binding Uv365Intensity}" />
|
||||||
<Slider Classes="vertical" Value="{Binding Uv254Intencity}" />
|
<Slider Classes="vertical" Value="{Binding Uv254Intensity}" />
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ using Avalonia.Media;
|
|||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
|
||||||
using GSS2.Core.Extentions;
|
using GSS2.Core.UI.Extensions;
|
||||||
|
|
||||||
namespace GSS2.UI.Core;
|
namespace GSS2.UI.Core;
|
||||||
|
|
||||||
public class ZoomPanImage : Control
|
public class ZoomPanImage : Control
|
||||||
{
|
{
|
||||||
private Point? _lastmousePosition = null;
|
private Point? _lastMousePosition = null;
|
||||||
private Dictionary<int, Point>? _lastTouchPositions = null;
|
private Dictionary<int, Point>? _lastTouchPositions = null;
|
||||||
private float _zoom = 1;
|
private float _zoom = 1;
|
||||||
private float _panX = 0;
|
private float _panX = 0;
|
||||||
@@ -103,7 +103,7 @@ public class ZoomPanImage : Control
|
|||||||
_panY = 0f;
|
_panY = 0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_lastmousePosition = ea.GetPosition(this);
|
_lastMousePosition = ea.GetPosition(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ea.Pointer.Type == PointerType.Touch)
|
else if (ea.Pointer.Type == PointerType.Touch)
|
||||||
@@ -124,7 +124,7 @@ public class ZoomPanImage : Control
|
|||||||
if (ea.Pointer.Type == PointerType.Mouse)
|
if (ea.Pointer.Type == PointerType.Mouse)
|
||||||
{
|
{
|
||||||
if (!ea.Properties.IsLeftButtonPressed)
|
if (!ea.Properties.IsLeftButtonPressed)
|
||||||
_lastmousePosition = null;
|
_lastMousePosition = null;
|
||||||
}
|
}
|
||||||
else if (ea.Pointer.Type == PointerType.Touch)
|
else if (ea.Pointer.Type == PointerType.Touch)
|
||||||
{
|
{
|
||||||
@@ -138,15 +138,15 @@ public class ZoomPanImage : Control
|
|||||||
{
|
{
|
||||||
if (ea.Pointer.Type == PointerType.Mouse)
|
if (ea.Pointer.Type == PointerType.Mouse)
|
||||||
{
|
{
|
||||||
if (_lastmousePosition is null || _zoom == 1) // Если кнопка не нажата или зум == 1, то ничего не делаем
|
if (_lastMousePosition is null || _zoom == 1) // Если кнопка не нажата или зум == 1, то ничего не делаем
|
||||||
{
|
{
|
||||||
base.OnPointerMoved(ea);
|
base.OnPointerMoved(ea);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var position = ea.GetPosition(this);
|
var position = ea.GetPosition(this);
|
||||||
_panX -= (float)(_lastmousePosition.Value.X - position.X);
|
_panX -= (float)(_lastMousePosition.Value.X - position.X);
|
||||||
_panY -= (float)(_lastmousePosition.Value.Y - position.Y);
|
_panY -= (float)(_lastMousePosition.Value.Y - position.Y);
|
||||||
_lastmousePosition = position;
|
_lastMousePosition = position;
|
||||||
}
|
}
|
||||||
else if (ea.Pointer.Type == PointerType.Touch)
|
else if (ea.Pointer.Type == PointerType.Touch)
|
||||||
{
|
{
|
||||||
@@ -163,11 +163,11 @@ public class ZoomPanImage : Control
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lastTouchPositions.Count() == 1 && _zoom != 1) // Если есть только одно прикосновение и зум != 1, то токлько перемещение
|
if (_lastTouchPositions.Count() == 1 && _zoom != 1) // Если есть только одно прикосновение и зум != 1, то только перемещение
|
||||||
{
|
{
|
||||||
var position = ea.GetPosition(this);
|
var position = ea.GetPosition(this);
|
||||||
_panX -= (float)(_lastTouchPositions[ea.Pointer.Id].X - position.X);
|
_panX -= (float)(_lastTouchPositions[ea.Pointer.Id].X - position.X);
|
||||||
_panY -= (float)(_lastTouchPositions[ea.Pointer.Id].Y - position.Y); // Ось Y инвертированна
|
_panY -= (float)(_lastTouchPositions[ea.Pointer.Id].Y - position.Y); // Ось Y инвертирована
|
||||||
_lastTouchPositions[ea.Pointer.Id] = position;
|
_lastTouchPositions[ea.Pointer.Id] = position;
|
||||||
}
|
}
|
||||||
else if (_lastTouchPositions.Count() == 2) // Если два прикосновения, то перемещение с приближением
|
else if (_lastTouchPositions.Count() == 2) // Если два прикосновения, то перемещение с приближением
|
||||||
|
|||||||
Reference in New Issue
Block a user