gpt4 book ai didi

android - 无法在Opencv(Android)中使API PointPolygonTest和flofloodFill的参数类型匹配

转载 作者:行者123 更新时间:2023-12-02 16:40:59 27 4
gpt4 key购买 nike

我确保参数类型与pointPolygonTest中的flofloodFillOpencv (Android )的API要求匹配。但是我仍然有参数类型不匹配的错误。
错误是

(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;
}

最佳答案

尝试:

MatOfPoint contour = contours.get(idx);
MatOfPoint2f ctr2f = new MatOfPoint2f();
contour.converTo(ctr2f, CvType.CV_32F); // or CvType.CV_32FC2

关于android - 无法在Opencv(Android)中使API PointPolygonTest和flofloodFill的参数类型匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22315528/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com