Dynamic pose line thickness (#16362)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Francesco Mattioli 2024-09-19 16:49:58 +02:00 committed by GitHub
parent 6dcc4a0610
commit ff2d268bdb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -419,7 +419,7 @@ class Annotator:
# Convert im back to PIL and update draw # Convert im back to PIL and update draw
self.fromarray(self.im) self.fromarray(self.im)
def kpts(self, kpts, shape=(640, 640), radius=5, kpt_line=True, conf_thres=0.25, kpt_color=None): def kpts(self, kpts, shape=(640, 640), radius=None, kpt_line=True, conf_thres=0.25, kpt_color=None):
""" """
Plot keypoints on the image. Plot keypoints on the image.
@ -436,6 +436,7 @@ class Annotator:
- Modifies self.im in-place. - Modifies self.im in-place.
- If self.pil is True, converts image to numpy array and back to PIL. - If self.pil is True, converts image to numpy array and back to PIL.
""" """
radius = radius if radius is not None else self.lw
if self.pil: if self.pil:
# Convert to numpy first # Convert to numpy first
self.im = np.asarray(self.im).copy() self.im = np.asarray(self.im).copy()
@ -471,7 +472,7 @@ class Annotator:
pos1, pos1,
pos2, pos2,
kpt_color or self.limb_color[i].tolist(), kpt_color or self.limb_color[i].tolist(),
thickness=2, thickness=int(np.ceil(self.lw / 2)),
lineType=cv2.LINE_AA, lineType=cv2.LINE_AA,
) )
if self.pil: if self.pil: