FingerprintTemplate creation throws ImageDecoder not found error

Issue #2 invalid
Vijay Kanta created an issue

I am trying to save list of candidates to memory in an arraylist. These candidates are coming from a server web api call and the fingerprints were saved in LARGEBLOB in sql. The response from server is in bytes. I use following code to parse and create a template

byte[] fingerprint = data.getJSONObject("fingerprint").getString("data").getBytes(); // buffer image

try {
    FingerprintTemplate template = new FingerprintTemplate(
        new FingerprintImage()
                .dpi(500)
                .decode(fingerprint)
    );
} catch...

I don’t know whether that’s the right way to get bytes. The response comes like this.

"fingerprint":{"type":"Buffer","data":[137,80,78,71,13,10,26,10...

The error I get while trying to create fingerprinttemplate from first code

Fingerprint couldn't be saved: Unsupported image format [ImageIO = 'java.lang.UnsupportedOperationException: Image decoder is not available.', Sanselan = 'java.lang.UnsupportedOperationException: Image decoder is not available.', WSQ = 'java.lang.IllegalArgumentException: This is not a WSQ image.', Android = 'java.lang.IllegalArgumentException: Unsupported image format.'].

Comments (2)

  1. Vijay Kanta reporter

    Yes, you’re right, I had to Base64 encode the complete byte stream coming from web server before throwing into the fingerprint template.

    JSONArray fingerprintArray = data.getJSONObject("fingerprint").getJSONArray("data"); // buffer image
    byte[] fingerprintBytes = new byte[fingerprintArray.length()];
    for(int j=0; j<fingerprintArray.length(); j++) {
        fingerprintBytes[j] = (byte) (((int) fingerprintArray.get(j)) & 0xFF);
    }
    
    Base64.encodeToString(fingerprintBytes, Base64.DEFAULT);
    

  2. Log in to comment