Android Question {SOLVED] Firebase ML-Vision error

saunwin

Active Member
Licensed User
Longtime User
Hello,
I need an OCR function and I'm currently using this library (thank you DonManfred).
I have an error (line 10 below)

** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzl@d47475b
Using Barcode Detector Processor
Error occurred on line: 76 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.ml.vision.barcode.FirebaseVisionBarcodeDetector com.google.firebase.ml.vision.FirebaseVision.getVisionBarcodeDetector()' on a null object reference
at com.google.firebase.samples.mlkit.barcodescanning.BarcodeScanningProcessor.<init>(BarcodeScanningProcessor.java:52)
at de.donmanfred.FirebaseDetectorwrapper.createCameraSource(FirebaseDetectorwrapper.java:479)
at de.donmanfred.FirebaseDetectorwrapper.Initialize(FirebaseDetectorwrapper.java:93)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)

B4X:
    Activity.LoadLayout("Layout1")
    spRegognizers.Clear
    spRegognizers.Add(vision.BARCODE_DETECTION)
    spRegognizers.Add(vision.TEXT_DETECTION)
    spRegognizers.Add(vision.IMAGE_LABEL_DETECTION)
    spRegognizers.Add(vision.FACE_DETECTION)
    spRegognizers.Add(vision.FACE_CONTOUR)
    'spRegognizers.Add(detector.CLASSIFICATION_FLOAT) ' Does not work
    'spRegognizers.Add(detector.CLASSIFICATION_QUANT) ' Does not work
    detector.Initialize("MLVision",CameraSourcePreview1,GraphicOverlay1,File.Combine(File.DirAssets,"clown_nose.png"),vision.BARCODE_DETECTION)
    detector.Facing = 0

Advice please
TIA
 

drgottjr

Expert
Licensed User
Longtime User
last week you weren't talking about firebase; just ocr. now its firebase ocr, which is different. are you set up for firebase apps? also by donmanfred's own admission, he couldn't get the firebase ocr part to work until erel eventually appeared with half a dozen manifest settings that nobody ever heard of. then everything worked. you'll have to track down the thread. first came the library, then a bunch of questions about why barcode and face worked but not ocr. one user wrote to donmanfred 4 or 5 times asking for the fix. eventually, erel posted additional manifest settings. follow the thread. you'll find it
 
Upvote 0

saunwin

Active Member
Licensed User
Longtime User
Hi Drgottjr, Yes I found the thread here I added the manifest lines and it now works. Thanks for the pointer.

Last weeks OCR code has been deprecated by DonManfred as the github project that was used was fairly old and had some methods in it that wouldn't work with sdk 23+ so it wouldn't have been able to go into playstore - hence changed tack and now looking at the firebase one. Which seems to work now (thanks to you :)
 
Upvote 0
Top