狗尾草007 2022-04-30 11:34 采纳率: 0%
浏览 94

在C#中使用opencv的findcontours函数,编写时没有报错,但运行该处代码,会报methodnofound,求解?

问题遇到的现象和发生背景

想要学习图像识别方面的知识,在利用C#编写查找轮廓时,代码编写没有直接报错,但运行该findcontours函数时就直接报错

问题相关代码,请勿粘贴截图
            Mat mat = Classimageconver.imageconver();
            Mat mat1 = Mat.Zeros(mat.Size(), mat.Type());
            Cv2.Threshold(mat, mat1, 50, 150, ThresholdTypes.Binary);
            Mat mat2 = Mat.Zeros(mat.Size(), mat.Type());

            Cv2.FindContours(mat1, out Point[][] points1, out HierarchyIndex[] hierarchyIndices, 
                RetrievalModes.Tree, ContourApproximationModes.ApproxSimple, new Point(0, 0));



            Scalar scalar = new Scalar(0, 0, 255);
            Cv2.DrawContours(mat, points1, -1, scalar, 1);
            imageconvertbitmap.Imageconvertbitmap(mat);
运行结果及报错内容

img

我的解答思路和尝试过的方法

通过排查发现,只要运行该函数方法,就会直接报错。但编写代码没有报错,怀疑是定义的两个输出函数points和hierarchyindices有问题,但不知道该怎么入手。

我想要达到的结果

因为是刚接触编程和图像识别方面的,所以只要能运行该函数,展现出图像的轮廓即可

  • 写回答

2条回答 默认 最新

  • xuzuning 2022-04-30 14:08
    关注

    OpenCvSharp.Cv2.FindContours

    不知道你的Cv2是什么

    评论

报告相同问题?

问题事件

  • 创建了问题 4月30日