11import { ImageSource } from "tns-core-modules/image-source" ;
2- import { MLKitDetectFacesOnDeviceOptions , MLKitDetectFacesOnDeviceResult } from "./" ;
2+ import { MLKitDetectFacesOnDeviceOptions , MLKitDetectFacesOnDeviceResult , MLKitDetectFacesResultBounds } from "./" ;
33import { MLKitOptions } from "../index" ;
44import { MLKitFaceDetection as MLKitFaceDetectionBase } from "./facedetection-common" ;
55
@@ -63,6 +63,19 @@ function getFaceDetector(options: MLKitDetectFacesOnDeviceOptions): any {
6363 return com . google . firebase . ml . vision . FirebaseVision . getInstance ( ) . getVisionFaceDetector ( faceDetectorOptions ) ;
6464}
6565
66+ function boundingBoxToBounds ( rect : any ) : MLKitDetectFacesResultBounds {
67+ return {
68+ origin : {
69+ x : rect . left ,
70+ y : rect . top
71+ } ,
72+ size : {
73+ width : rect . width ( ) ,
74+ height : rect . height ( )
75+ }
76+ }
77+ }
78+
6679export function detectFacesOnDevice ( options : MLKitDetectFacesOnDeviceOptions ) : Promise < MLKitDetectFacesOnDeviceResult > {
6780 return new Promise ( ( resolve , reject ) => {
6881 try {
@@ -80,6 +93,7 @@ export function detectFacesOnDevice(options: MLKitDetectFacesOnDeviceOptions): P
8093 for ( let i = 0 ; i < faces . size ( ) ; i ++ ) {
8194 const face = faces . get ( i ) ;
8295 result . faces . push ( {
96+ bounds : boundingBoxToBounds ( face . getBoundingBox ( ) ) ,
8397 smilingProbability : face . getSmilingProbability ( ) !== com . google . firebase . ml . vision . face . FirebaseVisionFace . UNCOMPUTED_PROBABILITY ? face . getSmilingProbability ( ) : undefined ,
8498 leftEyeOpenProbability : face . getLeftEyeOpenProbability ( ) !== com . google . firebase . ml . vision . face . FirebaseVisionFace . UNCOMPUTED_PROBABILITY ? face . getLeftEyeOpenProbability ( ) : undefined ,
8599 rightEyeOpenProbability : face . getRightEyeOpenProbability ( ) !== com . google . firebase . ml . vision . face . FirebaseVisionFace . UNCOMPUTED_PROBABILITY ? face . getRightEyeOpenProbability ( ) : undefined ,
0 commit comments