我正在尝试使用Xamarin在Android构建中使用OpenCV找到图像的轮廓(有关下面版本的详细信息).
我无法让FindCountours函数返回任何轮廓(列表为空),即使使用如下的伪图像也是如此.另一个问题是层状物体中存在一个轮廓.
它在Windows上从Python运行时有效.
有谁知道原因是什么?
Mat aoiHsv = new Mat(new Size(80, 80), CvType.Cv8uc3);
for (int i = 20; i < 40; i++)
{
for (int j = 20; j < 40; j++)
{
aoiHsv.Put(i,j, new byte[] {180, 255, 255});
}
}
Mat mask = new Mat();
OpenCV.Core.Core.InRange(aoiHsv, new Scalar(179, 255, 255), new Scalar(255, 255, 255), mask);
// Find contours
IList<MatOfPoint> contours = new List<MatOfPoint>();
Mat hierachy = new Mat();
Imgproc.FindContours(mask, contours, hierachy, Imgproc.RetrCcomp, Imgproc.ChainApproxNone);
Run Code Online (Sandbox Code Playgroud)
版本信息:
找到解决方案: …