Unverified Commit 0c493fc2 by justadudewhohacks Committed by GitHub

Merge pull request #135 from rawrmonstar/tegan/fix-detect-single-face-task

DetectSingleFaceTask should return faceDetection with highest confidence
parents 6b101dfd 346fec8c
...@@ -58,8 +58,14 @@ export class DetectAllFacesTask extends DetectFacesTaskBase<FaceDetection[]> { ...@@ -58,8 +58,14 @@ export class DetectAllFacesTask extends DetectFacesTaskBase<FaceDetection[]> {
export class DetectSingleFaceTask extends DetectFacesTaskBase<FaceDetection | undefined> { export class DetectSingleFaceTask extends DetectFacesTaskBase<FaceDetection | undefined> {
public async run(): Promise<FaceDetection | undefined> { public async run(): Promise<FaceDetection | undefined> {
return (await new DetectAllFacesTask(this.input, this.options)) const faceDetections = await new DetectAllFacesTask(this.input, this.options);
.sort((f1, f2) => f1.score - f2.score)[0] let faceDetectionWithHighestScore = faceDetections[0];
faceDetections.forEach(faceDetection => {
if (faceDetection.score > faceDetectionWithHighestScore.score) {
faceDetectionWithHighestScore = faceDetection;
}
});
return faceDetectionWithHighestScore;
} }
withFaceLandmarks(useTinyLandmarkNet: boolean = false): DetectSingleFaceLandmarksTask { withFaceLandmarks(useTinyLandmarkNet: boolean = false): DetectSingleFaceLandmarksTask {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment