feat: CameraService

Add stable optainitng of raw image from camera
This commit is contained in:
2026-01-15 14:58:11 +03:00
parent 717efe6781
commit ced7e294eb
8 changed files with 467 additions and 90 deletions
+29 -7
View File
@@ -6,21 +6,43 @@ namespace GSS2.Test;
public class Worker(
ILogger<Worker> logger,
AmineContentCalibrationContext calibrationContext,
LightsService lightsService
IHostApplicationLifetime applicationLifetime,
AmineContentCalibrationContext amineCalibrationContext,
AmineContentResultsContext amineResultsContext,
LightsService lightsService,
IlluminatorService illuminatorService,
CameraService cameraService
) : BackgroundService
{
private readonly ILogger<Worker> _logger = logger;
private readonly AmineContentCalibrationContext _calibrationContext = calibrationContext;
private readonly IHostApplicationLifetime _applicationLifetime = applicationLifetime;
private readonly AmineContentCalibrationContext _amineCalibrationContext = amineCalibrationContext;
private readonly AmineContentResultsContext _amineResultsContext = amineResultsContext;
private readonly LightsService _lightsService = lightsService;
private readonly IlluminatorService _illuminatorService = illuminatorService;
private readonly CameraService _cameraService = cameraService;
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{
await _cameraService.InitializeAsync(cancellationToken);
_ = _lightsService.Run(cancellationToken);
_ = _lightsService.SnowfallAsync(0.3, 1, Color.Aqua, cancellationToken);
while (!cancellationToken.IsCancellationRequested)
{
await Task.Delay(5000);
}
_illuminatorService.SetIntensity(0.5, 0, 0);
_illuminatorService.TurnOn();
await Task.Delay(1000);
var img = await _cameraService.CaptureImage(cancellationToken);
img?.SaveImage("IMAGE.png");
await Task.Delay(1000);
_illuminatorService.TurnOff();
await _lightsService.DisconnectAsync(cancellationToken);
applicationLifetime.StopApplication();
}
}
+6 -3
View File
@@ -6,8 +6,8 @@
"Microsoft.EntityFrameworkCore.Migrations": "Warning",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning",
"GSS2.Core.Hardware.LightsService": "Information",
"GSS2.Core.Hardware.IlluminatorService":"Information",
"GSS2.Core.Hardware.CameraService":"Information",
"GSS2.Core.Hardware.IlluminatorService": "Information",
"GSS2.Core.Hardware.CameraService": "Debug",
"LibCamera": "Information",
"LibCamera-Camera": "Information",
"LibCamera-RPI": "Information",
@@ -35,11 +35,14 @@
"MaxUv365PwmDuty": 1.0
},
"Camera": {
"CameraId": "",
"ViewFinderFrameBufferCount": 10,
"ViewFinderWidth": 1920,
"ViewFinderHeight": 1080,
"ViewFinderFps": 30,
"ImageCaptureFrameBufferCount": 2,
"ImageCaptureWidth": 4056,
"ImageCaptureHeight": 3080
"ImageCaptureHeight": 3040
},
"TemperatureHumidity": {
"Bus": 6,