如何从指纹读取器读取数据并在java中转换为图像文件

时间:2012-10-16 14:48:58

标签: java fingerprint

我必须从指纹读取器读取数据并转换为图像文件。我正在使用Digital Persona的设备U和U 4500与Platinum SDK。我是新的生物识别领域。到目前为止,我只能检测到设备是否与系统连接。请指导我如何完成此任务

我已使用此代码(仅用于检查设备是否正常工作)

import com.digitalpersona.onetouch.DPFPGlobal;
import com.digitalpersona.onetouch.DPFPSample;
import com.digitalpersona.onetouch.capture.DPFPCapture; 
import com.digitalpersona.onetouch.capture.event.DPFPDataEvent;
import com.digitalpersona.onetouch.capture.event.DPFPDataListener;
import com.digitalpersona.onetouch.capture.event.DPFPErrorEvent;
import com.digitalpersona.onetouch.capture.event.DPFPErrorListener;
import com.digitalpersona.onetouch.capture.event.DPFPReaderStatusAdapter; 
import com.digitalpersona.onetouch.capture.event.DPFPReaderStatusEvent;
import com.digitalpersona.onetouch.capture.event.DPFPReaderStatusListener;
import com.digitalpersona.onetouch.capture.event.DPFPSensorEvent;
import com.digitalpersona.onetouch.capture.event.DPFPSensorListener;


public class Demo {
public static void main(String args[]){
//byte[] a=null;
DPFPCapture capture=DPFPGlobal.getCaptureFactory().createCapture();
capture.addReaderStatusListener(new DPFPReaderStatusListener() {

    @Override
    public void readerDisconnected(DPFPReaderStatusEvent arg0) {
         //TODO Auto-generated method stub
        System.out.println("I m Dis-connected");

    }

    @Override
    public void readerConnected(DPFPReaderStatusEvent arg0) {
        // TODO Auto-generated method stub
        System.out.println("I m connected");
    }
});
capture.addSensorListener(new DPFPSensorListener() {

    @Override
    public void imageAcquired(DPFPSensorEvent arg0) {
        // TODO Auto-generated method stub
        System.out.print("acquired");
    }

    @Override
    public void fingerTouched(DPFPSensorEvent arg0) {
        // TODO Auto-generated method stub
        System.out.print("s");
    }

    @Override
    public void fingerGone(DPFPSensorEvent arg0) {
        // TODO Auto-generated method stub
        System.out.print("gone");
    }
});
capture.startCapture();
capture.addDataListener(new DPFPDataListener() {

    @Override
    public void dataAcquired(DPFPDataEvent arg0) {
        // TODO Auto-generated method stub
        DPFPSample sample=DPFPGlobal.getSampleFactory().createSample();
        sample=arg0.getSample();    
        byte a[]=sample.serialize();
        for(byte i:a){
            System.out.print(i);
        }
    }
});
capture.addErrorListener(new DPFPErrorListener() {

    @Override
    public void exceptionCaught(DPFPErrorEvent arg0) {
        // TODO Auto-generated method stub
        System.out.println("error");
    }

    @Override
    public void errorOccured(DPFPErrorEvent arg0) {
        // TODO Auto-generated method stub
        System.out.println("error");

    }
});

}
}

1 个答案:

答案 0 :(得分:1)

我目前正在研究Digital Persona指纹识别器,我实际上遇到了同样的问题,但现在我已经克服了它, 我认为添加Listeners的代码应该在init()方法中,并且还要在类的构造函数中启动init方法 主要方法应该只实例化Class。