Skip to content

Commit

Permalink
fix color channel order in visualization functions and docs (open-mml…
Browse files Browse the repository at this point in the history
  • Loading branch information
ly015 committed Mar 7, 2022
1 parent 3a5ce0d commit 8b6538a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/en/tutorials/2_new_dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ An example of the dataset config is as follows.

1. `name`: the keypoint name. The keypoint name must be unique.
2. `id`: the keypoint id.
3. `color`: ([R, G, B]) is used for keypoint visualization.
3. `color`: ([B, G, R]) is used for keypoint visualization.
4. `type`: 'upper' or 'lower', will be used in data augmetation.
5. `swap`: indicates the 'swap pair' (also known as 'flip pair'). When applying image horizontal flip, the left part will become the right part. We need to flip the keypoints accordingly.

Expand Down
2 changes: 1 addition & 1 deletion docs/zh_cn/tutorials/2_new_dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ configs/_base_/datasets/custom.py

1. `name`: 代表关键点的名称。一个数据集的每个关键点,名称必须唯一。
2. `id`: 关键点的标识号。
3. `color`: ([R, G, B]) 用于可视化关键点。
3. `color`: ([B, G, R]) 用于可视化关键点。
4. `type`: 分为 'upper' 和 'lower' 两种,用于数据增强。
5. `swap`: 表示与当前关键点,“镜像对称”的关键点名称。

Expand Down
18 changes: 6 additions & 12 deletions mmpose/core/visualization/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ def imshow_keypoints(img,
for kid, kpt in enumerate(kpts):
x_coord, y_coord, kpt_score = int(kpt[0]), int(kpt[1]), kpt[2]
if kpt_score > kpt_score_thr:
color = tuple(int(c) for c in pose_kpt_color[kid])
if show_keypoint_weight:
img_copy = img.copy()
r, g, b = pose_kpt_color[kid]
cv2.circle(img_copy, (int(x_coord), int(y_coord)),
radius, (int(r), int(g), int(b)), -1)
radius, color, -1)
transparency = max(0, min(1, kpt_score))
cv2.addWeighted(
img_copy,
Expand All @@ -157,9 +157,8 @@ def imshow_keypoints(img,
0,
dst=img)
else:
r, g, b = pose_kpt_color[kid]
cv2.circle(img, (int(x_coord), int(y_coord)), radius,
(int(r), int(g), int(b)), -1)
color, -1)

# draw links
if skeleton is not None and pose_link_color is not None:
Expand All @@ -172,7 +171,7 @@ def imshow_keypoints(img,
and pos2[1] > 0 and pos2[1] < img_h
and kpts[sk[0], 2] > kpt_score_thr
and kpts[sk[1], 2] > kpt_score_thr):
r, g, b = pose_link_color[sk_id]
color = tuple(int(c) for c in pose_link_color[sk_id])
if show_keypoint_weight:
img_copy = img.copy()
X = (pos1[0], pos2[0])
Expand All @@ -187,8 +186,7 @@ def imshow_keypoints(img,
(int(mX), int(mY)),
(int(length / 2), int(stickwidth)), int(angle), 0,
360, 1)
cv2.fillConvexPoly(img_copy, polygon,
(int(r), int(g), int(b)))
cv2.fillConvexPoly(img_copy, polygon, color)
transparency = max(
0, min(1, 0.5 * (kpts[sk[0], 2] + kpts[sk[1], 2])))
cv2.addWeighted(
Expand All @@ -199,11 +197,7 @@ def imshow_keypoints(img,
0,
dst=img)
else:
cv2.line(
img,
pos1,
pos2, (int(r), int(g), int(b)),
thickness=thickness)
cv2.line(img, pos1, pos2, color, thickness=thickness)

return img

Expand Down

0 comments on commit 8b6538a

Please sign in to comment.