• Introduction
  • Programmer's Guide
  • Technical Articles
  • API Documentation
Search Results for

    Show / Hide Table of Contents
    • ic4
      • BufferPool
      • DeviceEnum
      • DeviceInfo
      • Display
      • DisplayNotation
      • DisplayRenderPosition
      • DisplayStatistics
      • DisplayType
      • EmbeddedDisplay
      • ErrorCode
      • ExternalOpenGLDisplay
      • FloatRepresentation
      • FloatingDisplay
      • FrameMetaData
      • Grabber
      • HandleObject
      • IBufferAllocator
      • IC4Exception
      • IDisplay
      • ImageBuffer
      • ImageBuffer.CopyOptions
      • ImageBufferExtensions
      • ImageBufferExtensionsOpenCvSharp
      • ImageType
      • IntRepresentation
      • Interface
      • Library
      • LogLevel
      • LogTarget
      • PixelFormat
      • PixelFormatExtensions
      • PngCompressionLevel
      • PropBoolean
      • PropCategory
      • PropCommand
      • PropEnumEntry
      • PropEnumeration
      • PropFloat
      • PropId
      • PropIdBoolean
      • PropIdCommand
      • PropIdEnumeration
      • PropIdFloat
      • PropIdInteger
      • PropIdRegister
      • PropIdString
      • PropInteger
      • PropRegister
      • PropString
      • Property
      • PropertyIncrementMode
      • PropertyMap
      • PropertyType
      • PropertyVisibility
      • QueueSink
      • QueueSinkConnectedEventArgs
      • QueueSinkEventArgs
      • QueueSinkQueueSizes
      • Sink
      • SinkMode
      • SinkType
      • SnapSink
      • SnapSinkAllocationStrategy
      • StreamSetupOption
      • StreamStatistics
      • TransportLayerType
      • VersionInfoFlags
      • VideoWriter
      • VideoWriterType

    Class ImageBufferExtensionsOpenCvSharp

    Contains extension methods for ImageBuffer for interop with the OpenCvSharp library (https://github.com/shimat/opencvsharp).

    Inheritance
    object
    ImageBufferExtensionsOpenCvSharp
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: ic4
    Assembly: ic4dotnet.OpenCvSharp.dll
    Syntax
    public static class ImageBufferExtensionsOpenCvSharp
    Examples

    Since the members are extension methods, they can be called both explicitly and on image buffers directly, as if they were member functions.

    To call it as a member function, a using directive has to exist for the ic4 namespace:

    using ic4;
    

    // (...) // Get image buffer from somewhere ImageBuffer imageBuffer = GetImageBuffer(); // Create copy in a OpenCvSharp.Mat object OpenCvSharp.Mat mat = imageBuffer.CreateOpenCvCopy();

    Although not preferred, the function can also be called explicitly:

    // Get image buffer from somewhere
    ImageBuffer imageBuffer = GetImageBuffer();
    // Create copy in a OpenCvSharp.Mat object
    OpenCvSharp.Mat mat = ImageBufferExtensionsOpenCvSharp.CreateOpenCvCopy(imageBuffer);

    Methods

    CreateOpenCvCopy(ImageBuffer)

    Creates a copy of the image buffer and stores it in a OpenCvSharp.Mat.

    Declaration
    public static Mat CreateOpenCvCopy(this ImageBuffer buffer)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    Returns
    Type Description
    Mat

    A OpenCvSharp.Mat containing a copy of the image data in the passed image buffer.

    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null

    NotSupportedException

    The pixel format of the image buffer is not supported.

    CreateOpenCvWrap(ImageBuffer)

    Wraps the passed image buffer in a OpenCvSharp.Mat.

    Declaration
    public static Mat CreateOpenCvWrap(this ImageBuffer buffer)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    Returns
    Type Description
    Mat

    A OpenCvSharp.Mat using the image buffer's memory as pixel storage

    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null

    NotSupportedException

    Data of the image buffer's pixel format cannot be wrapped in a OpenCvSharp.Mat.

    IsOpenCvWrapSupported(ImageBuffer)

    Checks whether CreateOpenCvWrap(ImageBuffer) can work on the image buffer's pixel format.

    Declaration
    public static bool IsOpenCvWrapSupported(this ImageBuffer buffer)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    Returns
    Type Description
    bool

    true, if the contents of the image buffer can be wrapped in a OpenCvSharp.Mat, otherwise false.

    Remarks

    Wrapping the contents of an image buffer in a OpenCvSharp.Mat is only possible if the pixel format is one of the following:

    • Mono8 or any Bayer8 format
    • Mono16 or any Bayer16 format
    • BGRa8, BGR8 or BGRa16
    • YCbCr422_8 or YUV422_8
    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null

    In this article
    Copyright ©️ 2024 The Imaging Source Europe GmbH www.theimagingsource.com