IDSImaging.Peak.AFL
2.1.0
Prefix Reserved
dotnet add package IDSImaging.Peak.AFL --version 2.1.0
NuGet\Install-Package IDSImaging.Peak.AFL -Version 2.1.0
<PackageReference Include="IDSImaging.Peak.AFL" Version="2.1.0" />
<PackageVersion Include="IDSImaging.Peak.AFL" Version="2.1.0" />
<PackageReference Include="IDSImaging.Peak.AFL" />
paket add IDSImaging.Peak.AFL --version 2.1.0
#r "nuget: IDSImaging.Peak.AFL, 2.1.0"
#:package IDSImaging.Peak.AFL@2.1.0
#addin nuget:?package=IDSImaging.Peak.AFL&version=2.1.0
#tool nuget:?package=IDSImaging.Peak.AFL&version=2.1.0
IDS peak AFL for .NET
The IDS peak AFL provides host-based automatic control algorithms for IDS cameras. It allows you to implement high-performance Autofocus, Auto-Exposure, Auto-Gain, and Auto-White Balance using the computer's CPU, providing more flexibility than on-camera hardware controllers.
Installation
Install the package via NuGet:
dotnet add package IDSImaging.Peak.AFL
Requirements
- IDS peak runtime: Ensure the IDS peak software is installed on the host system to provide the necessary transport layer drivers.
Quickstart
using System;
using System.Collections.Generic;
using API = IDSImaging.Peak.API;
using IDSImaging.Peak.API.Core.Nodes;
using IDSImaging.Peak.AFL;
class ProcessingBrightnessCallback : IDSImaging.Peak.AFL.ProcessingBrightnessCallback
{
public ProcessingBrightnessCallback(Controller controller) : base(controller)
{
}
public override void callback(peak_afl_process_data_brightness data)
{
Console.WriteLine($"ProcessingBrightnessCallback: Mean {data.mean} Component: {data.controller_component}");
}
}
class ProcessingFocusCallback : IDSImaging.Peak.AFL.ProcessingFocusCallback
{
public ProcessingFocusCallback(Controller controller) : base(controller)
{
}
public override void callback(peak_afl_process_data_focus data)
{
Console.WriteLine($"ProcessingFocusCallback: Focus {data.focus_value} Sharpness {data.sharpness_value}");
}
}
class ProcessingWhitebalanceCallback : IDSImaging.Peak.AFL.ProcessingWhitebalanceCallback
{
public ProcessingWhitebalanceCallback(Controller controller) : base(controller)
{
}
public override void callback(peak_afl_process_data_whitebalance data)
{
Console.WriteLine(
$"ProcessingWhitebalanceCallback: " +
$"Mean (R/G/B) {data.mean_r}/{data.mean_g}/{data.mean_b} " +
$"Component: {data.controller_component}");
}
}
class FinishedCallback : IDSImaging.Peak.AFL.FinishedCallback
{
public FinishedCallback(Controller controller) : base(controller)
{
m_controller = controller;
}
public override void callback()
{
Console.WriteLine($"ControllerFinishedCallback for {m_controller.Type()}!");
}
private Controller m_controller;
}
class ComponentExposureFinishedCallback : IDSImaging.Peak.AFL.ComponentExposureFinishedCallback
{
public ComponentExposureFinishedCallback(Controller controller) : base(controller)
{
}
public override void callback()
{
Console.WriteLine("ControllerComponentExposureFinishedCallback!");
}
}
class Program
{
static void Main(string[] args)
{
API.Library.Initialize();
Library.Init();
try
{
var deviceManager = API.DeviceManager.Instance();
deviceManager.Update();
var cams = deviceManager.Devices();
if (cams.Count == 0)
{
throw new SystemException("No camera found!");
}
using var openedCam = cams[0].OpenDevice(API.Core.DeviceAccessType.Control);
using var remoteNodemap = openedCam.RemoteDevice().NodeMaps()[0];
using var dataStream = openedCam.DataStreams()[0].OpenDataStream();
remoteNodemap.FindNode<EnumerationNode>("UserSetSelector").SetCurrentEntry("Default");
remoteNodemap.FindNode<CommandNode>("UserSetLoad").Execute();
remoteNodemap.FindNode<CommandNode>("UserSetLoad").WaitUntilDone();
var payloadSize = Convert.ToUInt32(remoteNodemap.FindNode<IntegerNode>("PayloadSize").Value());
var bufferCountMinRequired = dataStream.NumBuffersAnnouncedMinRequired();
for (var bufferCount = 0; bufferCount < bufferCountMinRequired; ++bufferCount)
{
var buffer = dataStream.AllocAndAnnounceBuffer(payloadSize, IntPtr.Zero);
dataStream.QueueBuffer(buffer);
}
// AFL Setup
using var manager = new Manager(remoteNodemap);
using var gain = new IDSImaging.Peak.IPL.Gain();
manager.SetGainIPL(gain);
var callbackHandles = new List<object>();
var brightnessController = manager.CreateController(peak_afl_controllerType.PEAK_AFL_CONTROLLER_TYPE_BRIGHTNESS);
brightnessController.BrightnessComponentSetMode(
peak_afl_controller_brightness_component.PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_EXPOSURE,
peak_afl_controller_automode.PEAK_AFL_CONTROLLER_AUTOMODE_ONCE
);
callbackHandles.Add(new ProcessingBrightnessCallback(brightnessController));
callbackHandles.Add(new FinishedCallback(brightnessController));
callbackHandles.Add(new ComponentExposureFinishedCallback(brightnessController));
if (manager.IsControllerSupported(peak_afl_controllerType.PEAK_AFL_CONTROLLER_TYPE_WHITE_BALANCE))
{
var whitebalanceController = manager.CreateController(peak_afl_controllerType.PEAK_AFL_CONTROLLER_TYPE_WHITE_BALANCE);
whitebalanceController.SetMode(peak_afl_controller_automode.PEAK_AFL_CONTROLLER_AUTOMODE_ONCE);
callbackHandles.Add(new ProcessingWhitebalanceCallback(whitebalanceController));
callbackHandles.Add(new FinishedCallback(whitebalanceController));
}
if (manager.IsControllerSupported(peak_afl_controllerType.PEAK_AFL_CONTROLLER_TYPE_AUTOFOCUS))
{
var focusController = manager.CreateController(peak_afl_controllerType.PEAK_AFL_CONTROLLER_TYPE_AUTOFOCUS);
focusController.SetMode(peak_afl_controller_automode.PEAK_AFL_CONTROLLER_AUTOMODE_ONCE);
callbackHandles.Add(new ProcessingFocusCallback(focusController));
callbackHandles.Add(new FinishedCallback(focusController));
}
Console.WriteLine("ControllerCount:" + manager.ControllerList().Count);
remoteNodemap.FindNode<IntegerNode>("TLParamsLocked").SetValue(1);
dataStream.StartAcquisition();
remoteNodemap.FindNode<CommandNode>("AcquisitionStart").Execute();
remoteNodemap.FindNode<CommandNode>("AcquisitionStart").WaitUntilDone();
for (var i = 0; i < 100; i++)
{
try
{
using var buffer = dataStream.WaitForFinishedBuffer(1000);
using var img = API.IPLExtension.BufferToImage(buffer);
dataStream.QueueBuffer(buffer);
// Process the image in the autofeature manager, which will
// apply all the actions of associated controllers.
// Skip processing if another image is still being processed.
var isProcessing = manager.Status();
if (!isProcessing)
{
manager.Process(img);
}
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
remoteNodemap.FindNode<CommandNode>("AcquisitionStop").Execute();
remoteNodemap.FindNode<CommandNode>("AcquisitionStop").WaitUntilDone();
dataStream.KillWait();
dataStream.StopAcquisition(API.Core.AcquisitionStopMode.Default);
dataStream.Flush(API.Core.DataStreamFlushMode.DiscardAll);
foreach (var buffer in dataStream.AnnouncedBuffers())
{
dataStream.RevokeBuffer(buffer);
}
remoteNodemap.FindNode<IntegerNode>("TLParamsLocked").SetValue(0);
foreach (var cb in callbackHandles)
{
(cb as IDisposable)?.Dispose();
}
callbackHandles.Clear();
}
catch (System.SystemException e)
{
Console.WriteLine("Exception: " + e.Message);
}
finally
{
Library.Exit();
API.Library.Close();
}
}
}
Migration guide
Please note the following breaking namespace changes in the NuGet version of the IDSImaging.Peak.AFL bindings:
| Old | New |
|---|---|
| peak.afl | IDSImaging.Peak.AFL |
| std | IDSImaging.Peak.AFL.Std |
The .NET assembly and library names were also updated to reflect this:
| Old | New |
|---|---|
| ids_peak_afl_dotnet.dll | IDSImaging.Peak.AFL.dll |
| ids_peak_afl_dotnet_interface.dll | IDSImaging.Peak.AFL.Native.dll (Windows) |
| ids_peak_afl_dotnet_interface.so | libIDSImaging.Peak.AFL.Native.so (Linux) |
Important notes
- The NuGet package name, DLL name, and root namespace now match.
- Native interop libraries are named *.Native.*.
Documentation
Documentation is available here
Support
For technical support and inquiries, please contact support@ids-imaging.com or visit https://en.ids-imaging.com/support.html.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- IDSImaging.Peak.API (>= 1.17.0)
- IDSImaging.Peak.Common (>= 2.1.0)
- IDSImaging.Peak.IPL (>= 1.18.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.