diff --git a/mediapipe/tasks/web/components/containers/detection_result.d.ts b/mediapipe/tasks/web/components/containers/detection_result.d.ts index 287632f2d..590bd7340 100644 --- a/mediapipe/tasks/web/components/containers/detection_result.d.ts +++ b/mediapipe/tasks/web/components/containers/detection_result.d.ts @@ -27,13 +27,14 @@ export declare interface Detection { boundingBox?: BoundingBox; /** - * Optional list of keypoints associated with the detection. Keypoints - * represent interesting points related to the detection. For example, the - * keypoints represent the eye, ear and mouth from face detection model. Or - * in the template matching detection, e.g. KNIFT, they can represent the - * feature points for template matching. + * List of keypoints associated with the detection. Keypoints represent + * interesting points related to the detection. For example, the keypoints + * represent the eye, ear and mouth from face detection model. Or in the + * template matching detection, e.g. KNIFT, they can represent the feature + * points for template matching. Contains an empty list if no keypoints are + * detected. */ - keypoints?: NormalizedKeypoint[]; + keypoints: NormalizedKeypoint[]; } /** Detection results of a model. */ diff --git a/mediapipe/tasks/web/components/processors/detection_result.test.ts b/mediapipe/tasks/web/components/processors/detection_result.test.ts index 28b37ab0e..0fa8156ba 100644 --- a/mediapipe/tasks/web/components/processors/detection_result.test.ts +++ b/mediapipe/tasks/web/components/processors/detection_result.test.ts @@ -85,7 +85,8 @@ describe('convertFromDetectionProto()', () => { categoryName: '', displayName: '', }], - boundingBox: {originX: 0, originY: 0, width: 0, height: 0} + boundingBox: {originX: 0, originY: 0, width: 0, height: 0}, + keypoints: [] }); }); }); diff --git a/mediapipe/tasks/web/components/processors/detection_result.ts b/mediapipe/tasks/web/components/processors/detection_result.ts index 304b51a8e..4999ed31b 100644 --- a/mediapipe/tasks/web/components/processors/detection_result.ts +++ b/mediapipe/tasks/web/components/processors/detection_result.ts @@ -26,7 +26,7 @@ export function convertFromDetectionProto(source: DetectionProto): Detection { const labels = source.getLabelList(); const displayNames = source.getDisplayNameList(); - const detection: Detection = {categories: []}; + const detection: Detection = {categories: [], keypoints: []}; for (let i = 0; i < scores.length; i++) { detection.categories.push({ score: scores[i], @@ -47,7 +47,6 @@ export function convertFromDetectionProto(source: DetectionProto): Detection { } if (source.getLocationData()?.getRelativeKeypointsList().length) { - detection.keypoints = []; for (const keypoint of source.getLocationData()!.getRelativeKeypointsList()) { detection.keypoints.push({ diff --git a/mediapipe/tasks/web/vision/face_detector/face_detector_test.ts b/mediapipe/tasks/web/vision/face_detector/face_detector_test.ts index 28f602965..dfe84bb17 100644 --- a/mediapipe/tasks/web/vision/face_detector/face_detector_test.ts +++ b/mediapipe/tasks/web/vision/face_detector/face_detector_test.ts @@ -191,7 +191,8 @@ describe('FaceDetector', () => { categoryName: '', displayName: '', }], - boundingBox: {originX: 0, originY: 0, width: 0, height: 0} + boundingBox: {originX: 0, originY: 0, width: 0, height: 0}, + keypoints: [] }); }); }); diff --git a/mediapipe/tasks/web/vision/object_detector/object_detector_test.ts b/mediapipe/tasks/web/vision/object_detector/object_detector_test.ts index 1613f27d7..9c63eaba1 100644 --- a/mediapipe/tasks/web/vision/object_detector/object_detector_test.ts +++ b/mediapipe/tasks/web/vision/object_detector/object_detector_test.ts @@ -210,7 +210,8 @@ describe('ObjectDetector', () => { categoryName: '', displayName: '', }], - boundingBox: {originX: 0, originY: 0, width: 0, height: 0} + boundingBox: {originX: 0, originY: 0, width: 0, height: 0}, + keypoints: [] }); }); });