我确保参数类型与pointPolygonTest
中flofloodFill
和Opencv (Android )
的API要求相匹配。但是我仍然有Argument类型的错误不匹配。
错误是
(1)Imgproc类型中的方法pointPolygonTest(MatOfPoint2f, Point, boolean)
不适用于参数(MatOfPoint2f, Point, boolean)
。
(2)Imgproc类型中的方法floodFill(Mat, Mat, Point, Scalar)
不适用于参数(Mat, Mat, Point, Scalar)
。
我的节目是
public void Blob_alanysis(Mat roi_gray){
Size s = roi_gray.size();
Mat mask = Mat.ones(roi_gray.size(), CvType.CV_8UC1);
Mat process = roi_gray.clone();
roi_gray = Mat.zeros(roi_gray.size(), CvType.CV_8UC1);
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
final int gap = 5;
Imgproc.findContours(process, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
for (int idx = 0; idx < contours.size(); idx++) {
//search in 1st border
boolean touching = false;
MatOfPoint2f ctr2f = new MatOfPoint2f( contours.get(idx) );
for (int b = 0; b < s.height; b++) {
if(Imgproc.pointPolygonTest(ctr2f, new Point(0,1), true) > 0)
touching = true;
}
if(touching == false){
Mat contour = contours.get(idx);
Imgproc.floodFill(contour, mask, new Point(0,0), new Scalar(255, 255, 255));
}
}
return;
}
答案 0 :(得分:0)
尝试:
MatOfPoint contour = contours.get(idx);
MatOfPoint2f ctr2f = new MatOfPoint2f();
contour.converTo(ctr2f, CvType.CV_32F); // or CvType.CV_32FC2