Call to Reader.Capture() in DigitalPersona U.are.U SDK does not return

2.2k views Asked by At

I am developing an application for a DigitalPersona U.are.U 4500 fingerprint reader and using the U.are.U 2.2.3 SDK Java API.

The sample Java application that ships with the SDK works flawlessly.

However, when I try to do the same thing in my own sample application, the call to the Reader.Capture() method never returns, even though I can see the reader flashing when recording my fingerprint.

Below is a variation on the sample code I have tried with.

Other things I have tried:

  • Running the capture code in an instance of the class (i.e. not in a static context)
  • Running the capture operation in its own thread as well, but the results are the same.
  • Using the CaptureThread class from the demo application

The only difference I can see between my sample and the SDK sample app is that the latter is a graphical application. But why would that make a difference?

Unplugging the device causes the call to fail with an exception. That is about the only way I can get it to return.

import com.digitalpersona.uareu.*;

public class Main{

    static Reader r;

    public static void main(String[] args) {

        try {
            // Pick first available reader
            ReaderCollection rc = UareUGlobal.GetReaderCollection();
            rc.GetReaders();
            r = rc.get(0);
            if (r==null)
                return;

            // Open Reader
            r.Open(Reader.Priority.COOPERATIVE);
            System.out.println(r.GetStatus().status); // Outputs READY

            // The following call just hangs and never returns...
            Reader.CaptureResult
                    cr = r.Capture(Fid.Format.ISO_19794_4_2005, Reader.ImageProcessing.IMG_PROC_DEFAULT, 500, -1);
            System.out.println(cr.quality.name()); // Just to test

        } catch (UareUException e) {
            e.printStackTrace();
        }
    }
}

The last two parameters, the two ints, passed to the Capture method are the resolution and the timeout respectively; passing -1 for the timeout blocks indefinitely. This is taken from the sample application as well.

2

There are 2 answers

0
mydoghasworms On

I finally managed to get an example working.

Strange as it may seem, it only works in the context of a Java GUI application.

So, simply extending a JFrame and starting the reader capture on a separate thread seems to be sufficient.

This requirement is not specified anywhere in the SDK documentation that I can see.

UPDATE

It seems the problem is worse than I initially thought. Not only must the API be called in the context of a Java GUI application, but the GUI must also be in focus, otherwise the capture call simply does not return.

I have verified this with the example SDK applications. The Capture() method does not return if the apps are not in focus. This also applies to the C# examples, where the windows must be in focus, which suggests that this is built into the DLLs that ship with the solution.

This is terrible for our scenario, where we want to develop a local service that a browser can communicate with because, while the browser is in focus, obviously the Java application is not.

0
ratnesh On

I faced the similar issue and it can be fixed by opening a reader in exclusive mode as below,

    m_reader.Open(Reader.Priority.EXCLUSIVE);

Refer to below lines from documents,

public static final Reader.Priority COOPERATIVE

Client uses this priority to open reader in cooperative mode. Multiple clients with this priority are allowed. Client receives captured images if it has window with focus.

public static final Reader.Priority EXCLUSIVE

Client uses this priority to open reader exclusively. Only one client with this priority is allowed.