Jump to content
Sign in to follow this  
KMarb

kastri barcode scanning - should I use one or two TCameraComponents, and android vision lib problem

Recommended Posts

I'm using Dave Nottage's Kastri library and it is pretty great. I'm running into an issue, though, with the barcode feature and I'm not sure what's wrong.

 

I use a TCameraComponent to capture the user's selfie when they sign in with their employee ID number.

 

The code to create the camera is this:

 

      if not assigned (faceCamera) then
        begin
          faceCamera := TCameraComponent.Create (nil);
          faceCamera.Kind := FMX.Media.TCameraKind.FrontCamera;

          faceCamera.FocusMode := TFocusMode.ContinuousAutoFocus;
          faceCamera.OnSampleBufferReady := faceCameraSampleBufferReady;

        end;

 

I'm not having any problem with the "selfie" camera.

 

The barcode capability is only available in user interface after the user logs in. So, since my app has either the front or back camera on at any one time, my thinking is to use the same cameraComponent for the barcode scanning.

 

First question I have: should I instantiate a second TCameraComponent for the back camera? Or can I share the component for both functions?

 

I have another variable, barcodeCamera, but I don't instantiate a new object... I just point to faceCamera, like this:

 

procedure TfrmMain.StartBarcodeCamera;
begin
  barcode := '';  // the scan capability might find multiple barcodes, but only one will be returned in our code

 

  barcodeCamera := faceCamera; // 12/20/22 - share the camera component

 

  if barcodeCamera.Kind <> FMX.Media.TCameraKind.BackCamera then
    begin
      barcodeCamera.Kind := FMX.Media.TCameraKind.BackCamera;
      barcodeCamera.OnSampleBufferReady := barcodeCameraSampleBufferReady;
    end;

 

  FIsScanning := True;
 

  // i have a call to log.d to output to android log here, something like log.d ('StartBarcodeCamera - before barcodeCamera.Active := True');
  barcodeCamera.Active := True;
end;

I think I have a problem with google vision library not loading properly, so my 2nd question is, what does the following tell you, if anything, about my problem:

 

What's happening is that the camera doesn't show... the barcodeCameraSampleBufferReady fires, and I get a few lines in DeviceLens that might shed some light:

 

FMX: JCM Material: StartBarcodeCamera - before barcodeCamera.Active := True
type=1400 audit(0.0:77655): avc: denied { read } for name="u:object_r:vendor_camera_prop:s0" dev="tmpfs" ino=4472 scontext=u:r:untrusted_app:s0:c117,c256,c512,c768 tcontext=u:object_r:vendor_camera_prop:s0 tclass=file permissive=0
Access denied finding property "vendor.camera.hal1.packagelist"
send ACTION_CAMERA_DEVICE_STARTED
FMX: JCM Material: barcodeCameraSampleBufferReady
FMX: JCM Material: barcodeCameraSampleBufferReady - setting FProcessTime := Now
FMX: JCM Material: barcodeCameraSampleBufferReady - before FReader.Scan(FSectionBitmap)
Local module descriptor class for com.google.android.gms.vision.dynamite.barcode not found.
Considering local module com.google.android.gms.vision.dynamite.barcode:0 and remote module com.google.android.gms.vision.dynamite.barcode:0
Cannot load feature, fall back to load whole module.
Local module descriptor class for com.google.android.gms.vision.dynamite not found.
Unsupported class loader
Skipping duplicate class check due to unsupported classloader
Considering local module com.google.android.gms.vision.dynamite:0 and remote module com.google.android.gms.vision.dynamite:2703
Selected remote version of com.google.android.gms.vision.dynamite, version >= 2703
Dynamite loader version >= 2, using loadModule2NoCrashUtils
ClassLoader referenced unknown path:
Unsupported class loader
Verification of ix ix.d(android.content.Context, ir, java.lang.String) took 106.493ms
Wrote stack traces to '[tombstoned]'
Accessing hidden field Lsun/misc/Unsafe;->theUnsafe:Lsun/misc/Unsafe; (light greylist, reflection)
Considering local module com.google.android.gms.vision.barcode:0 and remote module com.google.android.gms.vision.barcode:224404100
Selected remote version of com.google.android.gms.vision.barcode, version >= 224404100
 

Share this post


Link to post
2 minutes ago, KMarb said:

Local module descriptor class for com.google.android.gms.vision.dynamite.barcode not found

It seems you may not have included the vision jars in your project, as per the readme.

 

Share this post


Link to post

use only 1 TCameraComponent, and before activate your scanning... change your cam.

the Buffer image should run in Thread-secondary context, not in main thread.

Share this post


Link to post
18 hours ago, Dave Nottage said:

It seems you may not have included the vision jars in your project, as per the readme.

 

Pretty sure I'm good with that step:

image.png.83965134a7ee660a6349db4f73296ce2.png

 

image.png.0eca1fdae5d4dfb1f90a7eb5c73dde29.png

 

  

One odd thing... I can add the two vision jars to 64-bit android but not 32-bit. I'm only testing in 64-bit right now, but will need 32-bit to work as well.

 

I had some success with scanning a few days ago, so I don't think it is my search path, but here is that:

 

image.png.8ed5dbcf4ba9eb7d5d8411b9251c0c94.png

image.png.4d801db4cebc919e0a53f7d604472ac8.png


I'm not sure where to set the Framework search path... Maybe that is the problem.

image.png

Share this post


Link to post
2 hours ago, KMarb said:

Pretty sure I'm good with that step:

Remove them from Android 64-bit and add them to Android 32-bit. The IDE knows to use them for both when added there.

Share this post


Link to post
1 hour ago, programmerdelphi2k said:

*.jar is in:

The jars I am referring to are not included in the jars that come with Delphi. 

A number of your answers are very plainly incorrect - you should refrain from doing that because it only confuses other developers.

Share this post


Link to post

I found my problem. I thought the barcodeHandler was only called when a barcode was found in the image. Things are working fine now. Thanks again for the help.

 

 

 

 

 

 

 

 

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×