想要学习图像识别方面的知识,在利用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);
通过排查发现,只要运行该函数方法,就会直接报错。但编写代码没有报错,怀疑是定义的两个输出函数points和hierarchyindices有问题,但不知道该怎么入手。
因为是刚接触编程和图像识别方面的,所以只要能运行该函数,展现出图像的轮廓即可
OpenCvSharp.Cv2.FindContours
不知道你的Cv2是什么
追加。
我又将所有的关于opencv的nuget包全部卸载后(开始时因为不知道具体要用那个,所以下载了好多个),又单独下载了opencv和opencvsharp3-arycpu这两个后,程序目前顺利运行。