Class ImageBufferExtensionsOpenCvSharp
Contains extension methods for ImageBuffer for interop with the OpenCvSharp library (https://github.com/shimat/opencvsharp).
Inherited Members
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 |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
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 |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
NotSupportedException | Data of the image buffer's pixel format cannot be wrapped in a |
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 |
|
Remarks
Wrapping the contents of an image buffer in a OpenCvSharp.Mat
is only possible
if the pixel format is one of the following:
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|