cvtools.utils.boxes module¶
-
cvtools.utils.boxes.
cut_polygon
(polygon, box)[源代码]¶ 求polygon与矩形框的交点,返回交点与外接矩形
参数: - polygon (list or np.array) -- 多边形,支持一维list或(K,2)list/array 不必保持点的顺序
- box (list or np.array) -- 必须是4个点形式list或array
返回: 第一个元素是交点, (K,2)数组;第二元素是交点的外接矩形,(4,)数组
返回类型: tuple
-
cvtools.utils.boxes.
get_min_area_rect
(cnt)[源代码]¶ 包装cv.minAreaRect
参数: cnt -- (np.ndarray): [x1, y1, x2, y2, x3, y3, x4, y4, ...] 返回: xywha:((x,y), (w,h), a), (x,y) is Oriented Bounding Box(OBB)'s center point, a is orientation, which range is [-90, 0)
-
cvtools.utils.boxes.
polygon_to_x1y1wh
(polygon)[源代码]¶ 求polygon的外接正矩形
参数: polygon (list or np.array) -- 多边形点集 返回: x1y1wh形式矩形 返回类型: tuple
-
cvtools.utils.boxes.
rotate_rect
(rect, center, angle)[源代码]¶ 一个数学问题:2x2矩阵(坐标)与旋转矩阵相乘. 在笛卡尔坐标系中,angle>0, 逆时针旋转; angle<0, 顺时针旋转
参数: - rect -- x1y1x2y2形式矩形
- center -- 旋转中心点
- angle -- 旋转角度,范围在(-180, 180)
返回: x1y1x2y2x3y3x4y4 format box
-
cvtools.utils.boxes.
rotate_rects
(rects, centers, angle)[源代码]¶ 一个数学问题:坐标矩阵与旋转矩阵相乘. 在笛卡尔坐标系中,angle>0, 逆时针旋转; angle<0, 顺时针旋转 return: x1y1x2y2x3y3x4y4 format box
参数: - rects -- x1y1x2y2形式list或array
- centers -- 旋转中心
- angle -- 旋转角度
-
cvtools.utils.boxes.
tran_xywha_to_rbox
(xywha)[源代码]¶ 包装opencv的cv.boxPoints函数
参数: xywha -- ((xy),(wh),angle)形式tuple或list, xy为中心点
-
cvtools.utils.boxes.
trans_polygon_to_rbox
(polygon)[源代码]¶ 求polygon的最小外接旋转矩形
参数: polygon -- 一维数组,或(K, 2)数组
-
cvtools.utils.boxes.
x1y1wh_to_x1y1x2y2
(xywh)[源代码]¶ Convert [x1 y1 w h] box format to [x1 y1 x2 y2] format. supported type: list, type and np.ndarray
-
cvtools.utils.boxes.
x1y1wh_to_x1y1x2y2x3y3x4y4
(xywh)[源代码]¶ Convert [x1 y1 w h] box format to [x1 y1 x2 y2 x3 y3 x4 y4] format. supported type: list, type and np.ndarray
-
cvtools.utils.boxes.
x1y1wh_to_xywh
(x1y1wh)[源代码]¶ Convert [x1 y1 w h] box format to [x y w h] format. supported type: list, type and np.ndarray
-
cvtools.utils.boxes.
x1y1x2y2_to_x1y1wh
(xyxy)[源代码]¶ Convert [x1 y1 x2 y2] box format to [x1 y1 w h] format.
-
cvtools.utils.boxes.
x1y1x2y2_to_xywh
(x1y1x2y2)[源代码]¶ Convert [x1 y1 x2 y2] box format to [x y w h] format.