Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
opencvsharpnet5cannyeffect.cs
using OpenCvSharp;
var capture = new VideoCapture(0);
var window = new Window("El Bruno - OpenCVSharp Effects demo");
var image = new Mat();
var imageNew = new Mat();
bool applyCanny = false;
bool run = true;
while (run)
{
capture.Read(image);
if (image.Empty()) break;
if (applyCanny)
imageNew = applyCannyEffect(image);
else
imageNew = image.Clone();
window.ShowImage(imageNew);
switch ((char)Cv2.WaitKey(100))
{
case (char)27: // Esc - Exit
run = false;
break;
case 'c':
applyCanny = !applyCanny;
break;
}
}
Mat applyCannyEffect(Mat image)
{
var newImage = new Mat();
Cv2.Canny(image, newImage, 50, 200);
return newImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.