Skip to content

Commit 4212ebb

Browse files
Tenflequesde-code
andauthored
added backwards compatibility with opencv 4.5.2 and below (keypoints) (#139)
* Update draw.py Error in draw TypeError: KeyPoint() missing required argument '_size' (pos 3) was size=3 change to _size=3 * handle get_cv_keypoints wraps cv2.KeyPoint(..., size=3), cv2.KeyPoint(..., _size=3) in try except block to handle change in argument name between opencv versions. * Update tf_bodypix/draw.py Co-authored-by: Daniel Ecer <de-code@users.noreply.github.com> * Update tf_bodypix/draw.py Co-authored-by: Daniel Ecer <de-code@users.noreply.github.com> Co-authored-by: Daniel Ecer <de-code@users.noreply.github.com>
1 parent 95aaddc commit 4212ebb

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

tf_bodypix/draw.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,25 @@ def get_adjacent_keypoints(
4141

4242

4343
def get_cv_keypoints(keypoints: Iterable[Keypoint]) -> List[cv2.KeyPoint]:
44-
return [
45-
cv2.KeyPoint(
46-
x=keypoint.position.x,
47-
y=keypoint.position.y,
48-
size=3
49-
)
50-
for keypoint in keypoints
51-
]
44+
try:
45+
return [
46+
cv2.KeyPoint(
47+
x=keypoint.position.x,
48+
y=keypoint.position.y,
49+
size=3
50+
)
51+
for keypoint in keypoints
52+
]
53+
except TypeError:
54+
# backwards compatibility with opencv 4.5.2 and below
55+
return [
56+
cv2.KeyPoint(
57+
x=keypoint.position.x,
58+
y=keypoint.position.y,
59+
_size=3
60+
)
61+
for keypoint in keypoints
62+
]
5263

5364

5465
def draw_skeleton(

0 commit comments

Comments
 (0)