Commit 016ff335 authored by Daniel Drake's avatar Daniel Drake

Enrolment infrastructure

parent b071f3cd
LIBRARY
=======
fingerprint data representation
debugging messages
fingerprint data classifcation by device or device type
storage mechanism
enrollment
verification
imaging support
external imaging APIs
identification
external API documentation
test suite against NISTIR
test suite against NFIQ compliance set
DRIVERS
=======
......
......@@ -25,11 +25,10 @@
struct fp_dscv_dev *discover_device(struct fp_dscv_dev **discovered_devs)
{
struct fp_dscv_dev *ddev = NULL;
struct fp_dscv_dev *tmpdev;
int i;
for (i = 0; tmpdev = discovered_devs[i]; i++) {
const struct fp_driver *drv = fp_dscv_dev_get_driver(tmpdev);
for (i = 0; ddev = discovered_devs[i]; i++) {
const struct fp_driver *drv = fp_dscv_dev_get_driver(ddev);
printf("Found device claimed by %s driver\n",
fp_driver_get_full_name(drv));
return ddev;
......@@ -38,11 +37,49 @@ struct fp_dscv_dev *discover_device(struct fp_dscv_dev **discovered_devs)
return ddev;
}
struct fp_print_data *enroll(struct fp_dev *dev) {
struct fp_print_data *enrolled_print = NULL;
enum fp_enroll_status status;
printf("You will need to successfully scan your finger %d times to "
"complete the process.\n", fp_dev_get_nr_enroll_stages(dev));
do {
printf("Scan your finger now.\n");
status = fp_enroll_finger(dev, &enrolled_print);
switch (status) {
case FP_ENROLL_COMPLETE:
printf("Enroll complete!\n");
break;
case FP_ENROLL_FAIL:
printf("Enroll failed, something wen't wrong :(\n");
return NULL;
case FP_ENROLL_PASS:
printf("Enroll stage passed. Yay!\n");
break;
case FP_ENROLL_RETRY:
printf("Didn't quite catch that. Please try again.\n");
break;
}
} while (status != FP_ENROLL_COMPLETE);
if (!enrolled_print) {
fprintf(stderr, "Enroll complete but no print?\n");
return NULL;
}
printf("got a print!\n");
return enrolled_print;
}
int main(void)
{
int r;
int ret = 1;
struct fp_dscv_dev *ddev;
struct fp_dscv_dev **discovered_devs;
struct fp_dev *dev;
struct fp_print_data *data;
r = fp_init();
if (r < 0) {
......@@ -62,6 +99,21 @@ int main(void)
exit(1);
}
dev = fp_dev_open(ddev);
fp_dscv_devs_free(discovered_devs);
if (!dev) {
fprintf(stderr, "Could not open device.\n");
}
printf("Opened device. It's now time to enroll your finger.\n\n");
data = enroll(dev);
if (!data)
goto out_close;
ret = 0;
out_close:
fp_dev_close(dev);
return ret;
}
......@@ -162,6 +162,11 @@ API_EXPORTED const struct fp_driver *fp_dev_get_driver(struct fp_dev *dev)
return dev->drv;
}
API_EXPORTED int fp_dev_get_nr_enroll_stages(struct fp_dev *dev)
{
return dev->nr_enroll_stages;
}
API_EXPORTED const char *fp_driver_get_name(const struct fp_driver *drv)
{
return drv->name;
......@@ -172,6 +177,16 @@ API_EXPORTED const char *fp_driver_get_full_name(const struct fp_driver *drv)
return drv->full_name;
}
API_EXPORTED enum fp_enroll_status fp_enroll_finger(struct fp_dev *dev,
struct fp_print_data **print_data)
{
const struct fp_driver *drv = dev->drv;
if (!dev->nr_enroll_stages || !drv->enroll)
return FP_ENROLL_FAIL;
return drv->enroll(dev, print_data);
}
API_EXPORTED int fp_init(void)
{
usb_init();
......@@ -179,3 +194,4 @@ API_EXPORTED int fp_init(void)
return 0;
}
......@@ -32,6 +32,8 @@ struct fp_dev {
const struct fp_driver *drv;
usb_dev_handle *udev;
void *priv;
int nr_enroll_stages;
};
struct usb_id {
......@@ -48,6 +50,8 @@ struct fp_driver {
/* Device operations */
int (*init)(struct fp_dev *dev);
void (*exit)(struct fp_dev *dev);
enum fp_enroll_status (*enroll)(struct fp_dev *dev,
struct fp_print_data **print_data);
};
extern const struct fp_driver upekts_driver;
......
......@@ -35,11 +35,23 @@ const struct fp_driver *fp_dscv_dev_get_driver(struct fp_dscv_dev *dev);
struct fp_dev *fp_dev_open(struct fp_dscv_dev *ddev);
void fp_dev_close(struct fp_dev *dev);
const struct fp_driver *fp_dev_get_driver(struct fp_dev *dev);
int fp_dev_get_nr_enroll_stages(struct fp_dev *dev);
/* Drivers */
const char *fp_driver_get_name(const struct fp_driver *drv);
const char *fp_driver_get_full_name(const struct fp_driver *drv);
/* Enrolment */
enum fp_enroll_status {
FP_ENROLL_COMPLETE,
FP_ENROLL_FAIL,
FP_ENROLL_PASS,
FP_ENROLL_RETRY,
};
enum fp_enroll_status fp_enroll_finger(struct fp_dev *dev,
struct fp_print_data **print_data);
/* Data handling */
void fp_print_data_free(struct fp_print_data *data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment