forked from amkovkov/GranuSightSoftware2
feat: Camera settings + some refactor
This commit is contained in:
@@ -10,9 +10,13 @@ public partial class MainViewModel : ViewModelBase
|
||||
{
|
||||
private readonly ILogger<MainViewModel> _logger;
|
||||
private readonly CameraService _cameraService;
|
||||
private readonly IlluminatorService _illuminatorService;
|
||||
[ObservableProperty] private CameraViewModel _cameraViewModel;
|
||||
[ObservableProperty] private ResourcesViewModel _resourcesViewModel;
|
||||
[ObservableProperty] private OpenCvSharp.Mat? _image;
|
||||
[ObservableProperty] private OpenCvSharp.Mat? _image1;
|
||||
[ObservableProperty] private OpenCvSharp.Mat? _image2;
|
||||
[ObservableProperty] private OpenCvSharp.Mat? _image3;
|
||||
[ObservableProperty] private OpenCvSharp.Mat? _image4;
|
||||
[ObservableProperty] private IRelayCommand _buttonCaptureClick;
|
||||
[ObservableProperty] private IRelayCommand _buttonUpClick;
|
||||
[ObservableProperty] private IRelayCommand _buttonDownClick;
|
||||
@@ -20,15 +24,29 @@ public partial class MainViewModel : ViewModelBase
|
||||
[ObservableProperty] private bool _canScrollForward;
|
||||
[ObservableProperty] private bool _canScrollBackward;
|
||||
|
||||
public MainViewModel(ILogger<MainViewModel> logger, CameraViewModel cameraViewModel, ResourcesViewModel resourcesViewModel, CameraService cameraService)
|
||||
public MainViewModel(ILogger<MainViewModel> logger, CameraViewModel cameraViewModel, ResourcesViewModel resourcesViewModel, CameraService cameraService, IlluminatorService illuminatorService)
|
||||
{
|
||||
_logger = logger;
|
||||
_cameraService = cameraService;
|
||||
_illuminatorService = illuminatorService;
|
||||
CameraViewModel = cameraViewModel;
|
||||
ResourcesViewModel = resourcesViewModel;
|
||||
ButtonCaptureClick = new RelayCommand(() =>
|
||||
{
|
||||
Task.Run(() => cameraService.CaptureImage(CancellationToken.None, 10).ContinueWith(image => Image = image.Result));
|
||||
Task.Run(async () =>
|
||||
{
|
||||
_illuminatorService.TurnOn();
|
||||
_illuminatorService.SetIntensity(1, 0, 0);
|
||||
await _cameraService.CaptureImage(CancellationToken.None, 3).ContinueWith(image => Image1 = image.Result);
|
||||
_illuminatorService.SetIntensity(0, 1, 1);
|
||||
await _cameraService.CaptureImage(CancellationToken.None, 3).ContinueWith(image => Image2 = image.Result);
|
||||
_illuminatorService.SetIntensity(0, 1, 0);
|
||||
await _cameraService.CaptureImage(CancellationToken.None, 3).ContinueWith(image => Image3 = image.Result);
|
||||
_illuminatorService.SetIntensity(0, 0, 1);
|
||||
await _cameraService.CaptureImage(CancellationToken.None, 3).ContinueWith(image => Image4 = image.Result);
|
||||
_illuminatorService.SetIntensity(0, 0, 0);
|
||||
_illuminatorService.TurnOff();
|
||||
});
|
||||
});
|
||||
ButtonUpClick = new RelayCommand(() => CurrentIndex--);
|
||||
ButtonDownClick = new RelayCommand(() => CurrentIndex++);
|
||||
|
||||
Reference in New Issue
Block a user