Emgu Cv用灰色轮廓绘制轮廓线

时间:2018-06-11 08:01:25

标签: opencv emgucv

当前图片 Without adding the contour

我想为此图像添加轮廓,以便我可以用原始图像掩饰它

        var frame = capture.QueryFrame();
        var image = frame.ToImage<Gray, float>();
        var image_gray = image.Convert<Gray, float>().Sobel(0, 1, 3).Add(image.Sobel(1, 0, 3)).AbsDiff(new Gray(50.0));


        if (background == null)
        {
            background = image_gray;
            return;
        }

        image_gray = background.AbsDiff(image_gray);

        CvInvoke.Threshold(image_gray, image_gray, 150, 30, Emgu.CV.CvEnum.ThresholdType.Binary);
        Emgu.CV.Util.VectorOfVectorOfPoint contours = new Emgu.CV.Util.VectorOfVectorOfPoint();
        Mat heir = new Mat();
        CvInvoke.FindContours(image_gray, contours, heir,Emgu.CV.CvEnum.RetrType.External,ChainApproxMethod.ChainApproxSimple);
        CvInvoke.DrawContours(image_gray, contours, -1, new MCvScalar(255, 0, 0));
        Video.Image = image_gray;

错误:

  

Emgu.CV.Util.CvException:&#39; OpenCV:[开始]当模式时,FindContours仅支持CV_8UC1图像!= CV_RETR_FLOODFILL否则仅支持CV_32SC1图像&#39;

Error I got

0 个答案:

没有答案