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++);
|
||||
|
||||
@@ -10,12 +10,17 @@
|
||||
<Button Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" IsEnabled="{Binding CanScrollBackward}" Command="{Binding ButtonUpClick}"/>
|
||||
<Button Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" IsEnabled="{Binding CanScrollForward}" Command="{Binding ButtonDownClick}"/>
|
||||
<core:SectionPanel Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" ClipToBounds="True" CanScrollForward="{Binding CanScrollForward}" CanScrollBackward="{Binding CanScrollBackward}" CurrentIndex="{Binding CurrentIndex}">
|
||||
<ContentControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding ResourcesViewModel}" />
|
||||
<ContentControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding CameraViewModel}" />
|
||||
<Grid ColumnDefinitions="100, *">
|
||||
<Grid ColumnDefinitions="100,*">
|
||||
<Button Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Command="{Binding ButtonCaptureClick}"/>
|
||||
<core:OpenCvImage Grid.Column="1" Image="{Binding Image}" Background="Red" />
|
||||
<Grid Grid.Column="1" ColumnDefinitions="*,*" RowDefinitions="*,*" >
|
||||
<core:OpenCvImage Grid.Column="0" Grid.Row="0" Image="{Binding Image1}" />
|
||||
<core:OpenCvImage Grid.Column="1" Grid.Row="0" Image="{Binding Image2}" />
|
||||
<core:OpenCvImage Grid.Column="0" Grid.Row="1" Image="{Binding Image3}" />
|
||||
<core:OpenCvImage Grid.Column="1" Grid.Row="1" Image="{Binding Image4}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ContentControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding ResourcesViewModel}" />
|
||||
<!-- <ContentControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding CameraViewModel}" /> -->
|
||||
</core:SectionPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -32,19 +32,55 @@
|
||||
"Uv365RelayPin": 20,
|
||||
"FanPin": 21,
|
||||
"PwmFrequency": 200,
|
||||
"MaxWhitePwmDuty": 1.0,
|
||||
"MaxWhitePwmDuty": 0.03,
|
||||
"MaxUv254PwmDuty": 1.0,
|
||||
"MaxUv365PwmDuty": 1.0
|
||||
},
|
||||
"Camera": {
|
||||
"CameraId": "",
|
||||
"ViewFinderFrameBufferCount": 5,
|
||||
"CameraId": "/base/axi/pcie@1000120000/rp1/i2c@70000/imx477@1a",
|
||||
"ViewFinderFrameBufferCount": 5,
|
||||
"ViewFinderWidth": 4056,
|
||||
"ViewFinderHeight": 3040,
|
||||
"ViewFinderFps": 30,
|
||||
"ImageCaptureFrameBufferCount": 2,
|
||||
"ImageCaptureFrameBufferCount": 5,
|
||||
"ImageCaptureWidth": 4056,
|
||||
"ImageCaptureHeight": 3040
|
||||
"ImageCaptureHeight": 3040,
|
||||
"CameraHardSettings": {
|
||||
"AeEnable": false,
|
||||
"ExposureValue": 8.0,
|
||||
"ExposureTime": 1000000,
|
||||
"ExposureTimeMode": "ExposureTimeModeManual",
|
||||
"AnalogueGain": 1.0,
|
||||
"AnalogueGainMode": "AnalogueGainModeManual",
|
||||
"AeFlickerMode": "FlickerOff",
|
||||
"AeFlickerPeriod": 5000,
|
||||
"Brightness": 0.0,
|
||||
"Contrast": 1.0,
|
||||
"AwbEnable": true,
|
||||
"ColourGains": [
|
||||
3.3,
|
||||
1.5
|
||||
],
|
||||
"ColourTemperature": 5500,
|
||||
"Saturation": 1.0,
|
||||
"Sharpness": 1.0,
|
||||
"ScalerCrop": [
|
||||
0,
|
||||
0,
|
||||
4056,
|
||||
3040
|
||||
],
|
||||
"FrameDurationLimits": [
|
||||
100000,
|
||||
694434742
|
||||
],
|
||||
"HdrMode": "HdrModeOff",
|
||||
"NoiseReductionMode": "NoiseReductionModeOff",
|
||||
"StatsOutputEnable": true,
|
||||
"SyncMode": "SyncModeOff",
|
||||
"SyncFrames": 1,
|
||||
"CnnEnableInputTensor": false
|
||||
}
|
||||
},
|
||||
"TemperatureHumidity": {
|
||||
"Bus": 6,
|
||||
|
||||
Reference in New Issue
Block a user