Skip to content

Instantly share code, notes, and snippets.

@elbruno
Created November 11, 2020 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbruno/285554510aff6718923c9c7cc9dae0a9 to your computer and use it in GitHub Desktop.
Save elbruno/285554510aff6718923c9c7cc9dae0a9 to your computer and use it in GitHub Desktop.
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