using Emgu.CV; using Emgu.CV.CvEnum; using Emgu.CV.Structure; Imageimage = new Image ("image.png"); Image grayImage = image.Convert (); Image cannyImage = grayImage.Canny(100, 200); CvInvoke.Imshow("Canny Image", cannyImage);
using Emgu.CV; using Emgu.CV.CvEnum; using Emgu.CV.Structure; using Emgu.CV.Util; using System.Drawing; VideoCapture capture = new VideoCapture(); capture.Start(); Mat frame = new Mat(); VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint(); while (true) { capture.Read(frame); ImageThese examples use the Emgu.CV package which is a .NET wrapper for the OpenCV library.image = frame.ToImage (); Image grayImage = image.Convert (); Image cannyImage = grayImage.Canny(100, 200); CvInvoke.FindContours(cannyImage, contours, null, RetrType.List, ChainApproxMethod.ChainApproxSimple); Image contourImage = new Image (grayImage.Size); for (int i = 0; i < contours.Size; i++) { CvInvoke.DrawContours(contourImage, contours, i, new MCvScalar(0, 0, 255)); } CvInvoke.Imshow("Canny Edge Detection", contourImage); if (CvInvoke.WaitKey(1) == 27) break; } capture.Stop();