plugin system docs
custom buttons for plugins calibration functions for Leeform
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Inspectron.Settings;
|
||||
using VisionBuilder.UI.Common;
|
||||
|
||||
namespace Hawkeye.VisionBuilder.UI.Sources.Raspberry.Libcamera;
|
||||
|
||||
public class CaptureSettings : ISettings
|
||||
{
|
||||
public string CameraName { get; }
|
||||
|
||||
public CaptureSettings(string cameraName)
|
||||
{
|
||||
CameraName = cameraName;
|
||||
}
|
||||
|
||||
public int Width { get; set; } = 2028;
|
||||
public int Height { get; set; } = 1520;
|
||||
public int ShutterSpeed { get; set; } = 10000;
|
||||
public int Framerate { get; set; } = 2;
|
||||
public double AwbGainRed { get; set; } = 3.86;
|
||||
public double AwbGainBlue { get; set; } = 1.46;
|
||||
|
||||
public string BuildArguments()
|
||||
{
|
||||
return $"--codec mjpeg -t0 --width {Width} --height {Height} " +
|
||||
$"--shutter {ShutterSpeed} --framerate {Framerate} " +
|
||||
$"--awbgains {AwbGainRed:F2},{AwbGainBlue:F2} --nopreview -o -";
|
||||
}
|
||||
|
||||
public void RegisterSettings(InspectronSettings settings)
|
||||
{
|
||||
settings.RegisterSimple(this, () => Width, CameraName + "/Sources/Libcamera", nameof(Width));
|
||||
settings.RegisterSimple(this, () => Height, CameraName + "/Sources/Libcamera", nameof(Height));
|
||||
settings.RegisterSimple(this, () => ShutterSpeed, CameraName + "/Sources/Libcamera", nameof(ShutterSpeed));
|
||||
settings.RegisterSimple(this, () => Framerate, CameraName + "/Sources/Libcamera", nameof(Framerate));
|
||||
settings.RegisterSimple(this, () => AwbGainRed, CameraName + "/Sources/Libcamera", nameof(AwbGainRed));
|
||||
settings.RegisterSimple(this, () => AwbGainBlue, CameraName + "/Sources/Libcamera", nameof(AwbGainBlue));
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,12 @@ namespace Hawkeye.VisionBuilder.UI.Sources.Raspberry.Libcamera
|
||||
{
|
||||
public class LibcameraImageSource : IImageSource, IVisionBuilderModule
|
||||
{
|
||||
private CaptureSettings _settings;
|
||||
|
||||
|
||||
public LibcameraImageSource(CaptureSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public async Task<Mat> GetImage(CancellationToken token)
|
||||
{
|
||||
@@ -25,15 +29,6 @@ namespace Hawkeye.VisionBuilder.UI.Sources.Raspberry.Libcamera
|
||||
byte[] JpegFooter = new byte[] { 0xff, 0xd9 };
|
||||
int ChunkSize = 1024;
|
||||
|
||||
ProcessStartInfo psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = "libcamera-vid",
|
||||
Arguments = "--codec mjpeg -t0 --width 2028 --height 1520 --shutter 10000 --framerate 16 --awbgains 3.86,1.46 --nopreview -o -",
|
||||
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false
|
||||
};
|
||||
|
||||
Channel<Mat> _imageChannel = Channel.CreateBounded<Mat>(new BoundedChannelOptions(1) { FullMode = BoundedChannelFullMode.DropOldest });
|
||||
|
||||
public void Start()
|
||||
@@ -46,6 +41,14 @@ namespace Hawkeye.VisionBuilder.UI.Sources.Raspberry.Libcamera
|
||||
|
||||
private void StartLoop()
|
||||
{
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = "rpicam-vid",
|
||||
Arguments = _settings.BuildArguments(),
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false
|
||||
};
|
||||
|
||||
using (Process process = Process.Start(psi))
|
||||
using (BinaryReader br = new BinaryReader(process.StandardOutput.BaseStream))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user