@@ -56,6 +56,33 @@ function getGravity(value) {
5656 return null ;
5757}
5858
59+ function detectionTypeToNative ( detectionType : DetectionType ) {
60+ switch ( detectionType ) {
61+ case DetectionType . All :
62+ return TNSMLKitDetectionType . All ;
63+ case DetectionType . Barcode :
64+ return TNSMLKitDetectionType . Barcode ;
65+ case DetectionType . DigitalInk :
66+ return TNSMLKitDetectionType . DigitalInk ;
67+ case DetectionType . Face :
68+ return TNSMLKitDetectionType . Face ;
69+ case DetectionType . Image :
70+ return TNSMLKitDetectionType . Image ;
71+ case DetectionType . Object :
72+ return TNSMLKitDetectionType . Object ;
73+ case DetectionType . CustomObject :
74+ return TNSMLKitDetectionType . CustomObject ;
75+ case DetectionType . Pose :
76+ return TNSMLKitDetectionType . Pose ;
77+ case DetectionType . Text :
78+ return TNSMLKitDetectionType . Text ;
79+ case DetectionType . Selfie :
80+ return TNSMLKitDetectionType . Selfie ;
81+ default :
82+ return TNSMLKitDetectionType . None ;
83+ }
84+ }
85+
5986export class MLKitView extends MLKitViewBase {
6087 _device : AVCaptureDevice ;
6188 _preview : AVCaptureVideoPreviewLayer ;
@@ -202,42 +229,7 @@ export class MLKitView extends MLKitViewBase {
202229 }
203230
204231 [ detectionTypeProperty . setNative ] ( value ) {
205- let type = 10 ; /* None */
206- switch ( value ) {
207- case DetectionType . All :
208- type = 8 ;
209- break ;
210- case DetectionType . Barcode :
211- type = 0 ;
212- break ;
213- case DetectionType . DigitalInk :
214- type = 1 ;
215- break ;
216- case DetectionType . Face :
217- type = 2 ;
218- break ;
219- case DetectionType . Image :
220- type = 3 ;
221- break ;
222- case DetectionType . Object :
223- type = 4 ;
224- break ;
225- case DetectionType . CustomObject :
226- type = 5 ;
227- break ;
228- case DetectionType . Pose :
229- type = 6 ;
230- break ;
231- case DetectionType . Text :
232- type = 7 ;
233- break ;
234- case DetectionType . Selfie :
235- type = 9 ;
236- break ;
237- default :
238- type = 10 ;
239- break ;
240- }
232+ const type = detectionTypeToNative ( value ) ;
241233 this . _setupDetectors ( ) ;
242234 this . _mlkitHelper . detectorType = type ;
243235 }
@@ -823,39 +815,7 @@ export function detectWithStillImage(image: any, options?: StillImageDetectionOp
823815 reject ( 'Please use a valid Image' ) ;
824816 }
825817
826- let type = 9 ; /* None */
827- switch ( options ?. detectorType ) {
828- case DetectionType . All :
829- type = 7 ;
830- break ;
831- case DetectionType . Barcode :
832- type = 0 ;
833- break ;
834- case DetectionType . DigitalInk :
835- type = 1 ;
836- break ;
837- case DetectionType . Face :
838- type = 2 ;
839- break ;
840- case DetectionType . Image :
841- type = 3 ;
842- break ;
843- case DetectionType . Object :
844- type = 4 ;
845- break ;
846- case DetectionType . Pose :
847- type = 5 ;
848- break ;
849- case DetectionType . Text :
850- type = 6 ;
851- break ;
852- case DetectionType . Selfie :
853- type = 8 ;
854- break ;
855- default :
856- type = 9 ;
857- break ;
858- }
818+ const type = detectionTypeToNative ( options ?. detectorType ) ;
859819
860820 TNSML . processImage (
861821 nativeImage ,
0 commit comments