216 private bool _disposed;
227 _monoConversion.IsEnabled =
false;
228 PixelFormat format = _finalConversion.OutputPixelFormat;
230 _unpack.ProcessingPolicy = _processingPolicy;
231 _unpack.TargetBitDepth = bitDepth;
233 _debayer.ProcessingPolicy = _processingPolicy;
234 _debayer.TargetBitDepth = bitDepth;
256 private static int Version => 1;
261 public override string TypeId =>
"DefaultPipeline";
287 get => _processingPolicy;
288 set => UpdateProcessingPolicy(value);
296 get => _finalConversion.OutputPixelFormat;
297 set => UpdateOutputPixelFormat(value);
420 get => _autoFeatureModule;
424 _autoFeatureModule = value;
426 _colorCorrection.SetAutoFeatureModule(_autoFeatureModule);
437 GC.SuppressFinalize(
this);
454 private void Dispose(
bool disposing)
466 _autoFeatureModule =
null;
469 foreach (
IModule? module
in GetModules())
471 var mod = module as IDisposable;
485 protected override IReadOnlyList<IModule> GetModules()
487 if (_autoFeatureModule ==
null)
489 return new List<IModule>
491 _unpack, _hotpixel, _binning, _decimation, _transformation, _gain, _debayer, _colorCorrection,
493 _sharpening, _toneCurveCorrection, _finalConversion
497 return new List<IModule>
499 _unpack, _hotpixel, _binning, _decimation, _transformation, _gain, _debayer, _colorCorrection,
501 _monoConversion, _sharpening, _toneCurveCorrection, _finalConversion
511 private IReadOnlyList<IFeature> GetFeatures()
513 return new List<IFeature>
549 using var archive =
new Archive();
551 IReadOnlyList<IModule> moduleList = GetModules();
552 var modules =
new List<IArchive>(moduleList.Count);
554 foreach (
IModule? module
in moduleList)
561 moduleArchive.
SetArchive(
"Data", moduleDataArchive);
562 modules.Add(moduleArchive);
565 archive.SetArchiveArray(
"Modules", modules);
566 archive.SetInt64(
"Version", Version);
567 archive.SetString(
"Type",
TypeId);
568 archive.SetString(
"Creation", GetCurrentIsoUtcTime());
570 var stream =
new MemoryStream();
572 serializer.Write(archive, stream);
574 return Utils.FromUtf8(stream.ToArray());
614 var stream =
new MemoryStream(
Utils.ToUtf8(settings));
617 IArchive archive = deserializer.Read(stream);
618 using var dispose = archive as IDisposable;
620 var version = archive.
GetInt64(
"Version");
624 $
"The 'Version' entry {version} in the settings string is invalid! Must be at least 1.");
627 var pipelineType = archive.
GetString(
"Type");
628 if (pipelineType !=
TypeId)
631 $
"The settings for {pipelineType} are not compatible with this pipeline ({TypeId}).");
634 IReadOnlyList<IModule> modules = GetModules();
636 var archiveMap =
new Dictionary<string, IArchive>();
637 IReadOnlyList<IArchive> moduleArchives = archive.
GetArchiveArray(
"Modules");
639 foreach (
IArchive? moduleArchive
in moduleArchives)
641 using var disposeModuleArchive = moduleArchive as IDisposable;
642 var moduleType = moduleArchive.
GetString(
"Type");
644 archiveMap.Add(moduleType, data);
649 foreach (
IModule? module
in modules)
651 if (!archiveMap.TryGetValue(module.
TypeId, out
IArchive? foundArchive))
661 foreach (
IArchive? moduleArchive
in archiveMap.Values)
663 using var disposeModuleArchive = moduleArchive as IDisposable;
681 foreach (
IModule? module
in GetModules())
684 module.IsEnabled =
true;
687 foreach (
IFeature? feature
in GetFeatures())
690 feature.IsEnabled =
true;
693 _monoConversion.IsEnabled =
false;
697 internal IModule? TryGetModuleById(
string typeId)
700 .FirstOrDefault(m => m !=
null && m.TypeId == typeId);
730 Image current = image;
731 foreach (
IModule? mod
in GetModules())
739 if (!ReferenceEquals(next, current))
742 if (!ReferenceEquals(current, image))
754 var moduleType = mod.
TypeId;
756 var errorText = $
"[{moduleType}] {what}";
760 case BackendStatus.PEAK_ICV_STATUS_DYNAMIC_DEPENDENCY_MISSING:
783 if (!ReferenceEquals(current, image))
792 return image.Data == current.Data ? current.
Copy() : current;
816 if (input is not
Image image)
819 $
"Casting from {input.GetType().Name} to the given type {typeof(Image).Name} is not supported!");
849 using var image =
new Image(imageView);
871 _unpack.ReleaseBuffers();
872 _debayer.ReleaseBuffers();
873 _monoConversion.ReleaseBuffers();
874 _finalConversion.ReleaseBuffers();
878 private static string GetCurrentIsoUtcTime()
880 DateTime utcNow = DateTime.UtcNow;
881 var isoTimestamp = utcNow.ToString(
"yyyy-MM-dd'T'HH:mm:ss'Z'");
887 _processingPolicy = policy;
889 _unpack.ProcessingPolicy = _processingPolicy;
890 _debayer.ProcessingPolicy = _processingPolicy;
893 private void UpdateOutputPixelFormat(
PixelFormat format)
897 var isBayerFormat = info.IsSingleChannel && info.HasChannel(
Channel.Bayer);
898 var isMonoFormat = info.IsSingleChannel && info.HasIntensityChannel;
904 else if (isMonoFormat)
913 if (info.HasChannel(
Channel.Red) && info.HasChannel(
Channel.Green)
914 && info.HasChannel(
Channel.Blue))
943 _monoConversion.IsEnabled = isMonoFormat;
945 _finalConversion.OutputPixelFormat = format;
947 var bitDepth = info.StorageBitsPerChannel;
948 _unpack.TargetBitDepth = bitDepth;
949 _debayer.TargetBitDepth = bitDepth;
IDSImaging.Peak.ICV.Backend.Types.peak_icv_status BackendStatus
IDSImaging.Peak.ICV.Backend.Utils Utils
IDSImaging.Peak.ICV.Pipeline.Types.DebayerChannelLayout DebayerChannelLayout
IDSImaging.Peak.ICV.Pipeline.Types.ProcessingPolicy ProcessingPolicy
IDSImaging.Peak.ICV.Pipeline.Types.DebayerConversionPolicy DebayerConversionPolicy
Base class for implementing a custom pipeline.
Occurs when reading from a file or stream that is incomplete, damaged, or in an unexpected format.
Base class for all exceptions thrown by the library.
Occurs when a required dependency is missing, the library is not initialized, or a misconfiguration a...
Occurs when an operation cannot be performed due to logical constraints (e.g., camera calibration wit...
Occurs when a requested operation is not implemented or supported (e.g., exporting to an unsupported ...
Occurs when a provided value falls outside the allowed valid range.
Image processing pipeline for sequential transformation of raw image frames.
SharpeningFeature Sharpening
Provides access to the sharpening feature for image detail enhancement.
BinningFeature Binning
Provides access to the binning feature for resolution reduction and noise improvement.
IAutoFeature? AutoFeatureModule
Auto feature module for automatic image adjustments.
DecimationFeature Decimation
Provides access to the decimation feature for resolution reduction by pixel skipping.
Image Process(IImageView imageView)
Applies the pipeline to an image view and returns the result as a new image.
Image Process(Image image)
Applies the pipeline to the given image and returns the result as a new image.
GammaFeature Gamma
Provides access to the gamma feature for brightness and contrast adjustments.
void ReleaseBuffers()
Frees unused internal buffers.
ColorCorrectionFeature ColorCorrection
Provides access to the color correction feature for color space transformations.
override void ResetToDefault()
Resets all modules in the pipeline to their default state. Also resets their enabled state.
SaturationFeature Saturation
Provides access to the saturation feature for color intensity adjustments.
override object Process(object input)
Applies the pipeline to the given image and returns the result as a new image.
void Dispose()
Releases all resources used by the DefaultPipeline.
DigitalBlackFeature DigitalBlack
Provides access to the digital black feature for sensor offset correction.
override string TypeId
The pipeline type identifier as a string, primarily used for serialization.
override string ExportSettingsToString()
Converts the current pipeline settings into a string format.
PixelFormat OutputPixelFormat
The current output pixel format as a PixelFormat enum.
HotpixelCorrectionFeature Hotpixel
Provides access to the hot pixel correction feature for defective pixel repair.
ChromaticAdaptionFeature ChromaticAdaption
Provides access to the chromatic adaption feature for adjusting to lighting conditions.
DefaultPipeline()
Creates a DefaultPipeline with default module settings.
MirrorFeature Mirror
Provides access to the mirror feature for image mirroring operations.
GainFeature Gain
Provides access to the gain feature for brightness and white balance adjustments.
override void ImportSettingsFromString(string settings)
Restores pipeline settings from a previously serialized string.
RotationFeature Rotation
Provides access to the rotation feature for image rotation operations.
Binning is used to decrease the image size.
Adjusts to changes in lighting conditions to maintain consistent color perception despite variations ...
Color correction applies a 3x3 Types.ColorCorrectionMatrix to the image.
Decimation is used to decrease the image size.
Digital black applies digital black correction to an image.
The GainFeature applies gain to the image.
Gamma applies an inverse gamma transformation to an image.
HotpixelCorrection detects and corrects hot pixels in camera images.
Mirror provides functionality to flip the image left-right or up-down.
Rotation provides fixed-angle rotation functionality.
Adjusts the saturation of an image by modifying a 3x3 Types.ColorCorrectionMatrix.
Sharpening applies a sharpening filter to enhance image detail.
Debayer is an image pipeline module that converts Bayer RAW images into standard color formats.
Downsampling is used to decrease the image size.
Image pipeline module for applying gain to the image.
Hotpixel correction is an image pipeline module for detecting and correcting hot pixels in camera ima...
Mono conversion is an image pipeline module that converts images to a monochrome format.
Sharpening is an image pipeline module that applies a sharpening filter to enhance image detail.
Tone curve correction is an image pipeline module that applies digital black correction and inverse g...
Unpack is an image pipeline module that converts packed pixel formats into corresponding unpacked Bay...
Deserializer for reading serialized data and converting it into an IArchive object.
Serializer for writing IArchive objects to an output stream.
Constructs an Image from an IImageView Instance.
Image Copy()
Creates a deep copy of the current Image.
@ Archive
Nested archive object.
Channel
Represents the various data channels in image or spatial data formats. /// This enumeration defines s...
PixelFormat
Each enumerator represents a specific pixel layout and bit-depth, used for interpreting raw image dat...
DownsamplingMode
Mode parameter for the downsampling algorithm.
Interface for modules that provide auto-feature functionality.
void SetGainModule(IGain? gainModule)
Called by the pipeline to set the gain module for the auto-feature module.
Interface for a module used within a pipeline.
object Process(object input)
Processes input data and returns the result.
string TypeId
The unique type identifier for this module implementation.
void ResetToDefault()
Resets the module to its default state.
Represents a hierarchical, strongly-typed key-value archive.
IArchive GetArchive(string key)
Retrieves a nested archive by key.
IArchive CreateArchive()
Creates a new, empty archive instance of the same concrete type.
IReadOnlyList< IArchive > GetArchiveArray(string key)
Retrieves an array of nested archives by key.
long GetInt64(string key)
Retrieves a 64-bit integer value by key.
void SetArchive(string key, IArchive value)
Stores a nested archive under the specified key.
string GetString(string key)
Retrieves a string value by key.
void SetString(string key, string value)
Stores a string value under the specified key.
void Serialize(IArchive archive)
Serializes the current object into the provided archive.
void Deserialize(IArchive archive)
Deserializes the object's state from the provided archive.
Interface for viewing image pixel data from arbitrary sources.
Abstract base class for all image processing pipeline features.
void ResetToDefault()
Restores the feature's default values.