Need help with SharpCV?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

SciSharp
137 Stars 27 Forks GNU General Public License v3.0 45 Commits 9 Opened issues

Description

A Computer Vision library for C# and F# that combines OpenCV and NDArray together in .NET Standard.

Services available

!
?

Need anything else?

Contributors list

SharpCV

A image library combines OpenCV and NumSharp together.

SharpCV
returns
Mat
object with
NDArray
supported, which makes it easier to do data manipulation like slicing.

Join the chat at https://gitter.im/publiclab/publiclab NuGet

How to use

Install OpenCV prebuild binary

PM> Install-Package SharpCV
PM> Install-Package OpenCvSharp4.runtime.win

Import SharpCV and OpenCV library

csharp
using SharpCV;
using static SharpCV.Binding;
Interact with
NDArray
NDArray kernel = new float[,]
{
    { 0, -1, 0 },
    { -1, 5, -1 },
    { 0, -1, 0 }
};

var mat = new Mat(kernel);

Assert.AreEqual((3, 3), mat.shape); Assert.AreEqual(kernel[0], mat.data[0]); // { 0, -1, 0 } Assert.AreEqual(kernel[1], mat.data[1]); // { -1, 5, -1 } Assert.AreEqual(kernel[2], mat.data[2]); // { 0, -1, 0 }

Pixel level access

var img = cv2.imread(imgSolar, IMREAD_COLOR.IMREAD_GRAYSCALE);
byte p = img[8, 8];
Assert.AreEqual(18, p);

img = cv2.imread(imgSolar); var (b, g, r) = img[8, 8]; Assert.AreEqual((32, 19, 11), (b, g, r));

Convert to black and white image

var img = cv2.imread("solar.jpg");
var gray = cv2.cvtColor(img, ColorConversionCodes.COLOR_RGB2GRAY);
var (ret, binary) = cv2.threshold(gray, 0, 255, ThresholdTypes.THRESH_BINARY | ThresholdTypes.THRESH_TRIANGLE);
cv2.imshow("black and white", binary);
cv2.waitKey(0);

Video capture from file or camera

csharp
var vid = cv2.VideoCapture("road.mp4");
var (loaded, frame) = vid.read();
while (loaded)
{
    (loaded, frame) = vid.read();
    cv2.imshow("video", frame);
}

If you want to learn more about the API implementation, please refer to the official documentation.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.