最大外接矩形
public static Rect boundingRect(Mat array)
- 参数一:array,输入的灰度图或者二维点集合。
该方法用于求取包含输入图像中物体轮廓或者二维点集的最大外接矩形。返回值为
Rect对象,可直接用rectangle()方法绘制矩形。
最小外接矩形
public static RotatedRect minAreaRect(MatOfPoint2f points)
参数一:points,输入的二维点集合。
该方法用于求取输入二维点集合的最小外接矩形。返回值为
RotateRect对象。RotateRect类型和Rect类型虽然都是表示矩形,但是在表示方式上有一定的区别。通过查看成员变量可以很明显的看到差异。Rect是通过左上角的坐标来定位,默认横平竖直,然后通过宽高确定大小。而RotateRect则是通过center确定位置,angle结合宽高,计算各顶点的坐标,从而确定矩形。
public class Rect {
public int x, y, width, height;
public Rect(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
……
}
public class

最低0.47元/天 解锁文章
3036

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



