Closed Chappie74 closed 2 weeks ago
Indeed, the docs are not correct. KeyPoints objects expects to hold N skeletons, with dimensions of (number_of_skeletons x number_of_keypoints x keypoint_dimensions)
.
@LinasKo are you working on "fix" for it (doc update), or should I do it?
@SkalskiP, I wasn't. Feel free!
Thanks for the update. @LinasKo in the meanwhile, can you please point me to an example of the data for this?
I want to use it for plotting facial landmarks (if that is even possible). I have a list of x,y pairs for the center point of each landmark.
It's definitely possible, though it works best if you have a model already, and can call one of our connector methods: from_inference
, from_ultralytics
, from_mediapipe
, etc.
I can't recall building a sv.KeyPoints
by hand, but it shouldn't be too hard.
import supervision as sv
import numpy as np
import cv2
# wget https://media.roboflow.com/notebooks/examples/dog.jpeg
image = cv2.imread("dog.jpeg")
points = np.array([
# Object 1
[[100, 100], [200, 100], [200, 200], [100, 200]],
# Object 2
[[150, 150], [250, 150], [250, 250], [150, 250]]
])
confidence = np.array([
[0.9, 0.8, 0.7, 0.6],
[0.9, 0.8, 0.7, 0.6]
])
class_id = np.array([0, 1])
key_points = sv.KeyPoints(
xy=points,
confidence=confidence,
class_id=class_id
)
edge_annotator = sv.EdgeAnnotator(
edges=[
(0, 1),
(1, 2),
(2, 3),
(3, 0)
]
)
image = edge_annotator.annotate(image.copy(), key_points)
sv.plot_image(image)
Makes sense now. Thank you.
@SkalskiP, This is very small, so I'm taking it and deploying together with other small fixes. Addressed by: #1448
Search before asking
Bug
I'm trying to use the KeyPoints class, with my xy data as [ [x1,y1], [x2,y1], .... ] Based on the information in the docs string this seems to be input needed. However, I run into an error.
The validation for the shape check does not seems to be consistent. Either that or I may be doing something wrong![image](https://github.com/user-attachments/assets/6e3f2b97-9510-4203-ae2c-feb0c4c9c5ef)
Environment
Supervision: 0.22.0 Python: 3.10
Minimal Reproducible Example
Additional
No response
Are you willing to submit a PR?