forked from amkovkov/GranuSightSoftware2
feat: CameraService
Add stable optainitng of raw image from camera
This commit is contained in:
+29
-7
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user