Created
November 11, 2020 17:30
-
-
Save elbruno/285554510aff6718923c9c7cc9dae0a9 to your computer and use it in GitHub Desktop.
opencvsharpnet5cannyeffect.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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