Update util.txt
Browse files
util.txt
CHANGED
|
@@ -81,6 +81,7 @@ def draw_bodypose(canvas: np.ndarray, keypoints: List[Keypoint]) -> np.ndarray:
|
|
| 81 |
The function expects the x and y coordinates of the keypoints to be normalized between 0 and 1.
|
| 82 |
"""
|
| 83 |
H, W, C = canvas.shape
|
|
|
|
| 84 |
|
| 85 |
if max(W, H) < 500:
|
| 86 |
ratio = 1.0
|
|
@@ -96,6 +97,7 @@ def draw_bodypose(canvas: np.ndarray, keypoints: List[Keypoint]) -> np.ndarray:
|
|
| 96 |
ratio = 6.0
|
| 97 |
else:
|
| 98 |
ratio = 7.0
|
|
|
|
| 99 |
stickwidth = 4
|
| 100 |
|
| 101 |
limbSeq = [
|
|
@@ -123,7 +125,7 @@ def draw_bodypose(canvas: np.ndarray, keypoints: List[Keypoint]) -> np.ndarray:
|
|
| 123 |
mY = np.mean(Y)
|
| 124 |
length = ((X[0] - X[1]) ** 2 + (Y[0] - Y[1]) ** 2) ** 0.5
|
| 125 |
angle = math.degrees(math.atan2(X[0] - X[1], Y[0] - Y[1]))
|
| 126 |
-
polygon = cv2.ellipse2Poly((int(mY), int(mX)), (int(length / 2), stickwidth), int(angle), 0, 360, 1)
|
| 127 |
cv2.fillConvexPoly(canvas, polygon, [int(float(c) * 0.6) for c in color])
|
| 128 |
|
| 129 |
for keypoint, color in zip(keypoints, colors):
|
|
@@ -133,11 +135,12 @@ def draw_bodypose(canvas: np.ndarray, keypoints: List[Keypoint]) -> np.ndarray:
|
|
| 133 |
x, y = keypoint.x, keypoint.y
|
| 134 |
x = int(x * W)
|
| 135 |
y = int(y * H)
|
| 136 |
-
cv2.circle(canvas, (int(x), int(y)), 4, color, thickness=-1)
|
| 137 |
|
| 138 |
return canvas
|
| 139 |
|
| 140 |
|
|
|
|
| 141 |
def draw_handpose(canvas: np.ndarray, keypoints: Union[List[Keypoint], None]) -> np.ndarray:
|
| 142 |
import matplotlib
|
| 143 |
"""
|
|
|
|
| 81 |
The function expects the x and y coordinates of the keypoints to be normalized between 0 and 1.
|
| 82 |
"""
|
| 83 |
H, W, C = canvas.shape
|
| 84 |
+
|
| 85 |
|
| 86 |
if max(W, H) < 500:
|
| 87 |
ratio = 1.0
|
|
|
|
| 97 |
ratio = 6.0
|
| 98 |
else:
|
| 99 |
ratio = 7.0
|
| 100 |
+
|
| 101 |
stickwidth = 4
|
| 102 |
|
| 103 |
limbSeq = [
|
|
|
|
| 125 |
mY = np.mean(Y)
|
| 126 |
length = ((X[0] - X[1]) ** 2 + (Y[0] - Y[1]) ** 2) ** 0.5
|
| 127 |
angle = math.degrees(math.atan2(X[0] - X[1], Y[0] - Y[1]))
|
| 128 |
+
polygon = cv2.ellipse2Poly((int(mY), int(mX)), (int(length / 2), int(stickwidth * ratio)), int(angle), 0, 360, 1)
|
| 129 |
cv2.fillConvexPoly(canvas, polygon, [int(float(c) * 0.6) for c in color])
|
| 130 |
|
| 131 |
for keypoint, color in zip(keypoints, colors):
|
|
|
|
| 135 |
x, y = keypoint.x, keypoint.y
|
| 136 |
x = int(x * W)
|
| 137 |
y = int(y * H)
|
| 138 |
+
cv2.circle(canvas, (int(x), int(y)), int(4 * ratio), color, thickness=-1)
|
| 139 |
|
| 140 |
return canvas
|
| 141 |
|
| 142 |
|
| 143 |
+
|
| 144 |
def draw_handpose(canvas: np.ndarray, keypoints: Union[List[Keypoint], None]) -> np.ndarray:
|
| 145 |
import matplotlib
|
| 146 |
"""
|