visibleKeypoints
Extract visible keypoints from keypoints detected by HRNet object keypoint detector
Since R2023b
Syntax
Description
extracts visible object keypoint locations from the object keypoint locations
visiblePoints
= visibleKeypoints(detector
,keypoints
,scores
,valid
)keypoints
detected by the HRNet object keypoint detector
detector
. The function obtains the locations of visible object
keypoints by using the keypoint validity values valid
, which are based on
the keypoint detection confidence scores scores
.
[
returns the detection confidence scores for the visible keypoints
visiblePoints
,visibleScores
,visibleLabels
] = visibleKeypoints(detector
,keypoints
,scores
,valid
)visibleScores
, and the labels assigned to the visible keypoints
visibleLabels
.
Examples
This example uses:
Read a sample image into the workspace.
I = imread("visionteam.jpg");
Crop and display one person from the image.
personBox = [18.51 42.51 137.21 370.98]; [personImg] = imcrop(I,personBox); figure imshow(personImg)
Specify a bounding box for the person in the image. You can use the bounding box region as input to the object keypoint detector to detect the person.
bbox = [3.87 21.845 118.97 345.91];
Create an HRNet object keypoint detector by using a pretrained HRNet deep learning network.
keypointDetector = hrnetObjectKeypointDetector("human-full-body-w32");
Detect the object keypoints of the person in the test image by using the pretrained HRNet object keypoint detector.
[keypoints,keypointScores,valid] = detect(keypointDetector,personImg,bbox);
Detect keypoints with keypoints confidence scores greater than 0.9
.
isValid = keypointScores > 0.9;
Extract visible keypoints from keypoints detected by HRNet object keypoint detector.
[visiblePoints,visibleScores,visibleLabels] = visibleKeypoints(keypointDetector,keypoints,keypointScores,isValid);
Insert and display visible keypoints.
detectedKeypoints = insertObjectKeypoints(personImg,visiblePoints{1},KeypointColor="yellow",KeypointSize=4);
figure
imshow(detectedKeypoints);
Display all the visible keypoint levels.
visibleLabels{1}
ans = 10×1 categorical
Nose
Left-eye
Right-eye
Left-ear
Right-ear
Left-shoulder
Right-shoulder
Left-elbow
Right-elbow
Left-wrist
Input Arguments
HRNet object keypoint detector, specified as an hrnetObjectKeypointDetector
object.
Locations of object keypoints detected in the input image or images, returned as one of these options:
17-by-2-by-M array — The keypoints come from a single test image. Each row in the array is of the form [x y] where x and y specify the location of a detected keypoint in an object. M is the number of objects in the image.
T-by-1 cell array — The keypoints come from an array of test images. T is the number of test images in the array. Each cell in the cell array contains a 17-by-2-by-M array specifying the keypoint detections for the M objects in the image.
Each object has 17 detected keypoints.
Data Types: double
Detection confidence scores for object keypoints, returned as one of these options:
17-by-M matrix — The keypoint scores come from a single test image. M is the number of objects in the image.
T-by-1 cell array — The keypoint scores come from an array of test images. T is the number of test images in the array. Each cell in the array contains a 17-by-M matrix indicating the detection scores for the keypoints of each of the M objects in an image.
Each object in an image has 17 has keypoint confidence scores. A higher score indicates higher confidence in the detection.
Data Types: double
Validity of the detected object keypoints, returned as one of these options:
17-by-M logical matrix — The keypoint validity values come from a single test image. M is the number of objects in the image.
T-by-1 cell array — The keypoint validity values come from an array of test images. T is the number of test images in the array. Each cell in the array contains a 17-by-M logical matrix indicating the keypoint validity values for the keypoints of each of the M objects in the corresponding image.
Each object in an image has 17 keypoint validity values. A value of
1
(true
) indicates a valid keypoint and
0
(false
) indicates an invalid keypoint.
Data Types: logical
Output Arguments
Location of visible keypoints detected in the input image or images, returned as one of these options:
17-by-2-by-M array — The visible keypoints come from a single test image. Each row in the array is of the form [x y] where x and y specify the location of a detected visible keypoint in an object. M is the number of objects in the image.
T-by-1 cell array — The visible keypoints come from an array of test images. T is the number of test images in the array. Each cell in the cell array has an N-by-2 matrix specifying the valid keypoint locations of the form [x, y]. N is the number of visible keypoints for each object in the image, as determined by the
scores
input argument. N is less than or equal to17
. M is the number of objects in the image.
Detection confidence scores of visible keypoints, returned as one of these options:
17-by-2-by-M array — The detection scores of visible keypoints come from a single test image. M is the number of objects in the image.
T-by-1 cell array — The detection scores of visible keypoints come from an array of test images. T is the number of test images in the array. Each cell in the cell array has an N-by-1 matrix specifying the visible keypoint scores. N is the number of visible keypoints for each object in the image, as determined by the
scores
input argument. N is less than or equal to17
. M is the number of objects in the image.
Validity labels of visible keypoints, returned as one of these options:
17-by-1-by-M array — The validity labels of visible keypoints come from a single test image. M is the number of objects in the image.
T-by-1 cell array — The validity labels of visible keypoints come from an array of test images. T is the number of test images in the array. Each cell in the cell array has an N-by-1 matrix specifying the valid keypoint labels. N is the number of visible keypoints for each object in the image, as determined by the
scores
input argument. N is less than or equal to17
. M is the number of objects in the image.
Version History
Introduced in R2023b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)