s0ju
s0ju

Reputation: 11

Capture using DigitalPersona 4500 on Android Studio

This is my code for capturing a fingerprint using DigitalPersona 4500. However it does not let me.

private void captureFP() {
        try {
            // Initialize the ReaderCollection
            ReaderCollection readers = UareUGlobal.GetReaderCollection(this);
            if (readers.isEmpty()) {
                runOnUiThread(() -> Toast.makeText(getApplicationContext(), "No fingerprint        readers available", Toast.LENGTH_SHORT).show());
                Log.d(TAG, "No fingerprint readers available");
                return;
            }

            // Get the first available reader
            Reader mReader = readers.get(0);

            // Open the reader
            mReader.Open(Reader.Priority.EXCLUSIVE);

            // Check the status of the reader
            Reader.Status status = mReader.GetStatus();
            if (status.status != Reader.ReaderStatus.READY) {
                Log.d(TAG, "Reader is not ready");
                return;
            }

            // Capture the fingerprint asynchronously
            mReader.CaptureAsync(
                    Fid.Format.ANSI_381_2004,
                    Reader.ImageProcessing.IMG_PROC_DEFAULT,
                    15000,  // Increased timeout to 15,000 milliseconds
                    -1,      // No timeout (-1)
                    new Reader.CaptureCallback() {
                        @Override
                        public void CaptureResultEvent(Reader.CaptureResult captureResult) {
                            if (captureResult != null && captureResult.image != null) {
                                // Process the captured fingerprint image
                                byte[] fingerprintImage = captureResult.image.getData();
                                Log.d(TAG, "Fingerprint captured successfully");
                            } else {
                                Log.d(TAG, "Failed to capture fingerprint: image is null");
                           }

                            // Close the reader after capturing
                            try {
                                mReader.Close();
                            runOnUiThread(() -> Toast.makeText(getApplicationContext(), "Reader is Closed!", Toast.LENGTH_SHORT).show());
                        } catch (UareUException e) {
                            Log.e(TAG, "UareUException while closing reader: " + e.getMessage());
                            e.printStackTrace();
                        }
                    }
                });

    } catch (UareUException e) {
        Log.e(TAG, "UareUException while capturing fingerprint: " + e.getMessage());
        e.printStackTrace();
    } catch (Exception e) {
        Log.e(TAG, "Exception while capturing fingerprint: " + e.getMessage());
        e.printStackTrace();
    }
}

this is what I'm getting on the logcat:

    2024-04-23 17:31:28.439 24258-24258 System.err              
    com.project.driversaferide           W      at 
    com.digitalpersona.uareu.jni.Dpfpdd.capture(Dpfpdd.java:182)
    2024-04-23 17:31:28.439 24258-24258 System.err              
    com.project.driversaferide           W      at   com.digitalpersona.uareu.dpfpdd.ReaderCollectionImpl$ReaderImpl.Capture(ReaderCollectionImpl.java:143)

The reader is getting opened and it is ready tho but still it won't let me capture

I have the necessary libraries for the DigitalPersona 4500 and still I'm stuck at this.

Upvotes: 0

Views: 136

Answers (0)

Related Questions