7

我正在尝试查找图像的轮廓,使用 OpenCV on android build with Xamarin(有关以下版本的详细信息)。

即使使用如下所示的伪图像,我也无法让 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);

版本信息:

  • OpenCV-3.1.0
  • 安卓 5.1 API 22

找到了解决方案: 轮廓列表必须是JavaList,即。

IList<MatOfPoint> contours = new JavaList<MatOfPoint>();
4

0 回答 0