NativeScript / mlkit

Apache License 2.0
24 stars 9 forks source link

Getting lastVisionImage from the face detection #25

Closed kriefsacha closed 2 years ago

kriefsacha commented 2 years ago

Hi,

In the previous plugin we could do event.object.lastVisionImage to have the last image of the face detection which is mandatory in my project.

I was doing like:

const source = new ImageSource();

      if (isAndroid) {
        const bmp = event.object.lastVisionImage.getBitmap();
        source.setNativeSource(bmp);
      }
      else source.setNativeSource(event.object.lastVisionImage);

But now it doesn't work.

I tried

event.object.get("lastVisionImage");

but its undefined.

Thank you.

Just two other things:

kriefsacha commented 2 years ago

@triniwiz is there any chance you look at this please ? Thats the last thing i need for my project..

triniwiz commented 2 years ago

Added in https://github.com/NativeScript/mlkit/commit/f98e08d5746b8d1c7607c13d4e1e82e278e85d45 , you will need to enable it first using retrieveLatestImage = true then grab the imagesource from latestImage

kriefsacha commented 2 years ago

Its not working @triniwiz , i got this error when putting retrieveLatestImage="true" in the MLKitView HTML ( i updated the plugins of course) :

TypeError: Cannot read property 'setRetrieveLatestImage' of undefined JS: at MLKitView.set retrieveLatestImage [as retrieveLatestImage] (file: node_modules\@nativescript\mlkit-core\index.android.js:72:0) JS: at ViewUtil.setPropertyInternal (file: node_modules\@nativescript\angular__ivy_ngcc\fesm2015\nativescript-angular.js:1515:0) JS: at ViewUtil.setProperty (file: node_modules\@nativescript\angular__ivy_ngcc\fesm2015\nativescript-angular.js:1467:0) JS: at EmulatedRenderer.setAttribute (file: node_modules\@nativescript\angular__ivy_ngcc\fesm2015\nativescript-angular.js:2029:0) JS: at setUpAttributes (file: node_modules\@angular\core__ivy_ngcc\fesm2015\core.js:2842:0) JS: at Module.ɵɵelementStart (file: node_modules\@angular\core__ivy_ngcc\fesm2015\core.js:14877:0) JS: at ScanComponent_GridLayout_66_Template (file: src\app\scan\scan.component.ts:174:21) JS: at executeTemplate (file: node_modules\@angular\core__ivy_ngcc\fesm2015\core.js:9618:0) JS: at render...

If i do it by the TS i got:

TypeError: classPrivateFieldGet(...).setRetrieveLatestImage is not a function JS: at MLKitView.set retrieveLatestImage [as retrieveLatestImage] (file: node_modules\@nativescript\mlkit-core\index.android.js:72:0) JS: at file: src\app\scan\scan.component.ts:1409:0 JS: at ZoneDelegate.invoke (file: node_modules\zone.js\fesm2015\zone.js:372:0) JS: at Object.onInvoke (file: node_modules\@angular\core__ivy_ngcc\fesm2015\core.js:28692:0) JS: at ZoneDelegate.invoke (file: node_modules\zone.js\fesm2015\zone.js:371:0) JS: at Zone.run (file: node_modules\zone.js\fesm2015\zone.js:134:0) JS: at NgZone.run (file: node_modules\@angular\core__ivy_ngcc__\fesm2015\core.js:28546:0) JS: at file: src\app\scan\scan.component.ts:1408:0 JS: at timer (file:///data/data/org.nativescript.VisualyScan/files/...

triniwiz commented 2 years ago

Please updated to the latest alpha

kriefsacha commented 2 years ago

I'm getting this @triniwiz , alpha7, and puted retrieveLatestImage = true on TS after that the MLKitView is loaded

TypeError: Cannot read property 'android' of undefined JS: at MLKitView.get latestImage [as latestImage] (file: node_modules\@nativescript\mlkit-core\index.android.js:83:0) JS: at ScanComponent.onFaceDetectionResult (file: src\app\scan\scan.component.ts:1415:0) JS: at ScanComponent_GridLayout_66_Template_MLKitView_detection_3_listener (file: src\app\scan\scan.component.ts:175:178) JS: at executeListenerWithErrorHandling (file: node_modules\@angular\core__ivy_ngcc\fesm2015\core.js:15327:0) JS: at Object.wrapListenerIn_markDirtyAndPreventDefault (file: node_modules\@angular\core__ivy_ngcc\fesm2015\core.js:15365:0) JS: at ZoneDelegate.invokeTask (file: node_modules\zone.js\fesm2015\zone.js:406:0) JS: at Object.onInvokeTask (file: node_modules\@angular\core__ivy_ngcc__\fesm2015\core.js:28679:0) JS: at ZoneDelegate.invokeTask (file:...

triniwiz commented 2 years ago

Thank you for testing, the .8 has the final fix for that

kriefsacha commented 2 years ago

I'll test tomorrow and let you know (it's 1:24 am for me now). Thank you

kriefsacha commented 2 years ago

Seems like working, opened a new ticket in @nativescript/firebase