Gab*_*mel 2 java android opencv
我正在为 android 开发一个 opencv 项目。我需要将变量从 转换MatOfPoint2f
为MatOfPoint
。以下是我的代码的相关部分:approx
is of type MatOfPoint2f
,我需要转换它,因为drawContours
使用 type ArrayList<MatOfPoint>
。
Imgproc.approxPolyDP(newMtx, approx, 0.02*peri, true);
approxMatOfPoint = (MatOfPoint) approx; // to convert
ArrayList<MatOfPoint> p = new ArrayList<>();
p.add(approxMatOfPoint);
Imgproc.drawContours(img, p, 0, new Scalar(0,255,0), 2);
Run Code Online (Sandbox Code Playgroud)
我解决了以下问题:
MatOfPoint approxf1 = new MatOfPoint();
...
Imgproc.approxPolyDP(newMtx, approx, 0.02*peri, true);
approx.convertTo(approxf1, CvType.CV_32S);
List<MatOfPoint> contourTemp = new ArrayList<>();
contourTemp.add(approxf1);
Imgproc.drawContours(img, contourTemp, 0, new Scalar(0, 255, 0), 2);
Run Code Online (Sandbox Code Playgroud)
干杯。
归档时间: |
|
查看次数: |
3166 次 |
最近记录: |