小编use*_*381的帖子

如何在opencv或emgu cv中检测三角形边缘?

在此输入图像描述

我正在使用Emgu CV,我想在图片中检测到两个锐利,首先我将图像转换为灰色,然后调用cvCanny,然后调用FindContours,但只找到一个轮廓,找不到三角形.

码:

 public static void Do(Bitmap bitmap, IImageProcessingLog log)
    {
        Image<Bgr, Byte> img = new Image<Bgr, byte>(bitmap);
        Image<Gray, Byte> gray = img.Convert<Gray, Byte>();
        using (Image<Gray, Byte> canny = new Image<Gray, byte>(gray.Size))
        using (MemStorage stor = new MemStorage())
        {
            CvInvoke.cvCanny(gray, canny, 10, 5, 3);
            log.AddImage("canny",canny.ToBitmap());

            Contour<Point> contours = canny.FindContours(
             Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE,
             Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_TREE,
             stor);

            for (int i=0; contours != null; contours = contours.HNext)
            {
                i++;
                MCvBox2D box = contours.GetMinAreaRect();

                Image<Bgr, Byte> tmpImg = img.Copy();
                tmpImg.Draw(box, new Bgr(Color.Red), 2);
                log.AddMessage("contours" + (i) +",angle:"+box.angle.ToString() …
Run Code Online (Sandbox Code Playgroud)

opencv emgucv

3
推荐指数
1
解决办法
8256
查看次数

标签 统计

emgucv ×1

opencv ×1