approxPolyDP
方法:
approxPolyDP( MatOfPoint2f curve,
MatOfPoint2f approxCurve,
double epsilon,
boolean closed)
函数作用:
用指定的精度逼近多边形曲线
参数:
curve:输入的轮廓点集合
approxCurve:输出的轮廓点集合。保存的是多边形的顶点。
epsilon:逼近的精度,原始曲线和逼近曲线间的最大值
closed:是否为封闭曲线。如果为 true,表示逼近曲线为封闭曲线。
例子:
//查找轮廓
List<MatOfPoint> contours = new ArrayList<>();
Imgproc.findContours(m, contours , new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
//多边形逼近
MatOfPoint2f curve = new MatOfPoint2f(contours.get(0).toArray());
MatOfPoint2f approxCurve = new MatOfPoint2f();
double epsilon = 15;
boolean closed = true;
ArrayList<MatOfPoint> list = new ArrayList<>();
Imgproc.approxPolyDP(curve, approx

approxPolyDP函数用于以指定精度逼近多边形曲线,处理输入轮廓点集合并输出多边形顶点。参数包括曲线、逼近曲线精度和是否封闭。在实际应用中,该函数可以简化复杂轮廓,例如在OpenCV与Java环境中处理图像时。

5588

被折叠的 条评论
为什么被折叠?



