我正在使用适用于 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);
}
现在我不确定如何继续检查我的contours
List (of a MatOfPoint
) 是否包含某个点p
。我检查了文档,MatOfPoint
似乎没有直接的方法来检查它是否包含某个点。