zerohertzLib.vision.convert ¶
Functions:
| Name | Description |
|---|---|
cwh2poly | Bbox 변환 |
cwh2xyxy | Bbox 변환 |
decode | Base64 decoding |
encode | Base64 encoding |
poly2area | 다각형의 면적을 산출하는 function |
poly2cwh | Bbox 변환 |
poly2mask | 다각형 좌표를 입력받아 mask로 변환 |
poly2ratio | 다각형의 bbox 대비 다각형의 면적 비율을 산출하는 function |
poly2xyxy | Bbox 변환 |
xyxy2cwh | Bbox 변환 |
xyxy2poly | Bbox 변환 |
_cwh2poly ¶
단일 bbox를 [cx, cy, w, h]에서 polygon으로 변환하는 helper function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Source code in zerohertzLib/vision/convert.py
_cwh2xyxy ¶
단일 bbox를 [cx, cy, w, h]에서 [x0, y0, x1, y1]로 변환하는 helper function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Source code in zerohertzLib/vision/convert.py
_list2np ¶
_poly2cwh ¶
단일 polygon을 [cx, cy, w, h]로 변환하는 helper function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Source code in zerohertzLib/vision/convert.py
_poly2mask ¶
Polygon을 mask로 변환하는 helper function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poly | NDArray[DTypeLike] | polygon 좌표 | required |
shape | tuple[int, int] | mask 크기 (height, width) | required |
Returns:
| Type | Description |
|---|---|
NDArray[bool] | polygon 영역에 대한 boolean mask |
Source code in zerohertzLib/vision/convert.py
_poly2xyxy ¶
단일 polygon을 [x0, y0, x1, y1]로 변환하는 helper function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Source code in zerohertzLib/vision/convert.py
_xyxy2cwh ¶
단일 bbox를 [x0, y0, x1, y1]에서 [cx, cy, w, h]로 변환하는 helper function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Source code in zerohertzLib/vision/convert.py
_xyxy2poly ¶
단일 bbox를 [x0, y0, x1, y1]에서 polygon으로 변환하는 helper function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Source code in zerohertzLib/vision/convert.py
cwh2poly ¶
Bbox 변환
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | list[int | float] | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Examples:
>>> zz.vision.cwh2poly([20, 30, 20, 20])
array([[10, 20],
[30, 20],
[30, 40],
[10, 40]])
>>> zz.vision.cwh2poly(np.array([[20, 30, 20, 20], [50, 75, 40, 50]]))
array([[[ 10, 20],
[ 30, 20],
[ 30, 40],
[ 10, 40]],
[[ 30, 50],
[ 70, 50],
[ 70, 100],
[ 30, 100]]])
Source code in zerohertzLib/vision/convert.py
cwh2xyxy ¶
Bbox 변환
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | list[int | float] | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Examples:
>>> zz.vision.cwh2xyxy([20, 30, 20, 20])
array([10, 20, 30, 40])
>>> zz.vision.cwh2xyxy(np.array([[20, 30, 20, 20], [50, 75, 40, 50]]))
array([[ 10, 20, 30, 40],
[ 30, 50, 70, 100]])
Source code in zerohertzLib/vision/convert.py
decode ¶
Base64 decoding
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img | str |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[uint8] | Base64 decoding image |
zz.vision.decode(img).shape (802, 802, 3)
Source code in zerohertzLib/vision/convert.py
encode ¶
poly2area ¶
다각형의 면적을 산출하는 function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poly | list[int | float] | NDArray[DTypeLike] | 다각형 ( | required |
Returns:
| Type | Description |
|---|---|
float | 다각형의 면적 |
Examples:
>>> poly = [[10, 10], [20, 10], [30, 40], [20, 60], [10, 20]]
>>> zz.vision.poly2area(poly)
550.0
>>> box = np.array([[100, 200], [1200, 200], [1200, 1000], [100, 1000]])
>>> zz.vision.poly2area(box)
880000.0
Source code in zerohertzLib/vision/convert.py
poly2cwh ¶
Bbox 변환
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | list[int | float] | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Examples:
>>> zz.vision.poly2cwh([[10, 20], [30, 20], [30, 40], [10, 40]])
array([20, 30, 20, 20])
>>> zz.vision.poly2cwh(np.array([[[10, 20], [30, 20], [30, 40], [10, 40]], [[30, 50], [70, 50], [70, 100], [30, 100]]]))
array([[20, 30, 20, 20],
[50, 75, 40, 50]])
Source code in zerohertzLib/vision/convert.py
poly2mask ¶
poly2mask(poly: list[int | float] | NDArray[DTypeLike] | list[NDArray[DTypeLike]], shape: tuple[int, int]) -> NDArray[bool]
다각형 좌표를 입력받아 mask로 변환
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poly | list[int | float] | NDArray[DTypeLike] | list[NDArray[DTypeLike]] | Mask의 꼭짓점 좌표 ( | required |
shape | tuple[int, int] | 출력될 mask의 shape | required |
Returns:
| Type | Description |
|---|---|
NDArray[bool] | 변환된 mask ( |
Examples:
>>> poly = [[10, 10], [20, 10], [30, 40], [20, 60], [10, 20]]
>>> mask1 = zz.vision.poly2mask(poly, (70, 100))
>>> mask1.shape
(70, 100)
>>> mask1.dtype
dtype('bool')
>>> poly = np.array(poly)
>>> mask2 = zz.vision.poly2mask([poly, poly - 10, poly + 20], (70, 100))
>>> mask2.shape
(3, 70, 100)
>>> mask2.dtype
dtype('bool')
Source code in zerohertzLib/vision/convert.py
poly2ratio ¶
다각형의 bbox 대비 다각형의 면적 비율을 산출하는 function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poly | list[int | float] | NDArray[DTypeLike] | 다각형 ( | required |
Returns:
| Type | Description |
|---|---|
float | 다각형의 bbox 대비 다각형의 비율 |
Examples:
>>> poly = [[10, 10], [20, 10], [30, 40], [20, 60], [10, 20]]
>>> zz.vision.poly2ratio(poly)
0.55
>>> box = np.array([[100, 200], [1200, 200], [1200, 1000], [100, 1000]])
>>> zz.vision.poly2ratio(box)
1.0
Source code in zerohertzLib/vision/convert.py
poly2xyxy ¶
Bbox 변환
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | list[int | float] | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Examples:
>>> zz.vision.poly2xyxy([[10, 20], [30, 20], [30, 40], [10, 40]])
array([10, 20, 30, 40])
>>> zz.vision.poly2xyxy(np.array([[[10, 20], [30, 20], [30, 40], [10, 40]], [[30, 50], [70, 50], [70, 100], [30, 100]]]))
array([[ 10, 20, 30, 40],
[ 30, 50, 70, 100]])
Source code in zerohertzLib/vision/convert.py
xyxy2cwh ¶
Bbox 변환
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | list[int | float] | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Examples:
>>> zz.vision.xyxy2cwh([10, 20, 30, 40])
array([20, 30, 20, 20])
>>> zz.vision.xyxy2cwh(np.array([[10, 20, 30, 40], [30, 50, 70, 100]]))
array([[20, 30, 20, 20],
[50, 75, 40, 50]])
Source code in zerohertzLib/vision/convert.py
xyxy2poly ¶
Bbox 변환
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
box | list[int | float] | NDArray[DTypeLike] |
| required |
Returns:
| Type | Description |
|---|---|
NDArray[DTypeLike] |
|
Examples:
>>> zz.vision.xyxy2poly([10, 20, 30, 40])
array([[10, 20],
[30, 20],
[30, 40],
[10, 40]])
>>> zz.vision.xyxy2poly(np.array([[10, 20, 30, 40], [30, 50, 70, 100]]))
array([[[ 10, 20],
[ 30, 20],
[ 30, 40],
[ 10, 40]],
[[ 30, 50],
[ 70, 50],
[ 70, 100],
[ 30, 100]]])
