Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android OpenCV-确定MatOfPoint是否包含点_Android_Opencv_Opencv4android - Fatal编程技术网

Android OpenCV-确定MatOfPoint是否包含点

Android OpenCV-确定MatOfPoint是否包含点,android,opencv,opencv4android,Android,Opencv,Opencv4android,我正在使用Android的OpenCV3库,我能够成功地扫描特定颜色的色块 我试图通过硬编码我想要的HSV值来扩展这种能力,以便能够扫描由特定颜色着色的网格中的轮廓。接下来我想做的是能够确定一个点是否包含在我的轮廓中 mDetector.process(inputMat); //inputMat is the mat that I process. List<MatOfPoint> contours = mDetector.getContours(); Mat colorLabel

我正在使用Android的OpenCV3库,我能够成功地扫描特定颜色的色块

我试图通过硬编码我想要的HSV值来扩展这种能力,以便能够扫描由特定颜色着色的网格中的轮廓。接下来我想做的是能够确定一个点是否包含在我的轮廓中

mDetector.process(inputMat); //inputMat is the mat that I process.
List<MatOfPoint> contours = mDetector.getContours();

Mat colorLabel = inputMat.submat(4, 68, 4, 68);
colorLabel.setTo(mBlobColorRgba);

Mat spectrumLabel = inputMat.submat(4, 4 + mSpectrum.rows(), 70, 70 + mSpectrum.cols());
mSpectrum.copyTo(spectrumLabel);

MatOfPoint2f approxCurve = new MatOfPoint2f();

//For each contour found
for (int i = 0; i < contours.size(); i++) {
    //Convert contours(i) from MatOfPoint to MatOfPoint2f
    MatOfPoint2f contour2f = new MatOfPoint2f( contours.get(i).toArray() );

    //Processing on mMOP2f1 which is in type MatOfPoint2f
    double approxDistance = Imgproc.arcLength(contour2f, true)*0.02;
    Imgproc.approxPolyDP(contour2f, approxCurve, approxDistance, true);

    Imgproc.drawContours(inputMat, contours, -1, new Scalar(0, 150, 0));

    Point p = new Point(x,y);
}
mDetector.process(inputMat)//inputMat是我处理的mat。
列表轮廓=mDetector.getContours();
Mat colorLabel=输入Mat.submat(4,68,4,68);
colorLabel.setTo(mBlobColorRgba);
Mat spectrumLabel=inputMat.submat(4,4+mSpectrum.rows(),70,70+mSpectrum.cols());
msspectrum.copyTo(spectrumLabel);
MatOfPoint2f approxCurve=新的MatOfPoint2f();
//对于找到的每个轮廓
对于(int i=0;i

现在我不知道如何继续检查我的
轮廓
列表(一个
MatOfPoint
)是否包含某个点
p
。我查看了
MatOfPoint
的文档,它似乎没有一种简单的方法来检查它是否包含某个点。

您必须使用实用程序类中声明的方法
pointpolyContest

感谢您的提醒。这真的很有帮助。