File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -58,8 +58,14 @@ export class DetectAllFacesTask extends DetectFacesTaskBase<FaceDetection[]> {
58
58
export class DetectSingleFaceTask extends DetectFacesTaskBase < FaceDetection | undefined > {
59
59
60
60
public async run ( ) : Promise < FaceDetection | undefined > {
61
- return ( await new DetectAllFacesTask ( this . input , this . options ) )
62
- . sort ( ( f1 , f2 ) => f1 . score - f2 . score ) [ 0 ]
61
+ const faceDetections = await new DetectAllFacesTask ( this . input , this . options ) ;
62
+ let faceDetectionWithHighestScore = faceDetections [ 0 ] ;
63
+ faceDetections . forEach ( faceDetection => {
64
+ if ( faceDetection . score > faceDetectionWithHighestScore . score ) {
65
+ faceDetectionWithHighestScore = faceDetection ;
66
+ }
67
+ } ) ;
68
+ return faceDetectionWithHighestScore ;
63
69
}
64
70
65
71
withFaceLandmarks ( useTinyLandmarkNet : boolean = false ) : DetectSingleFaceLandmarksTask {
You can’t perform that action at this time.
0 commit comments