Enrolment infrastructure
This commit is contained in:
parent
b071f3cdb9
commit
016ff33533
5 changed files with 90 additions and 6 deletions
6
TODO
6
TODO
|
@ -1,14 +1,14 @@
|
||||||
LIBRARY
|
LIBRARY
|
||||||
=======
|
=======
|
||||||
fingerprint data representation
|
debugging messages
|
||||||
|
fingerprint data classifcation by device or device type
|
||||||
storage mechanism
|
storage mechanism
|
||||||
enrollment
|
|
||||||
verification
|
verification
|
||||||
imaging support
|
imaging support
|
||||||
external imaging APIs
|
external imaging APIs
|
||||||
identification
|
identification
|
||||||
external API documentation
|
external API documentation
|
||||||
test suite against NISTIR
|
test suite against NFIQ compliance set
|
||||||
|
|
||||||
DRIVERS
|
DRIVERS
|
||||||
=======
|
=======
|
||||||
|
|
|
@ -25,11 +25,10 @@
|
||||||
struct fp_dscv_dev *discover_device(struct fp_dscv_dev **discovered_devs)
|
struct fp_dscv_dev *discover_device(struct fp_dscv_dev **discovered_devs)
|
||||||
{
|
{
|
||||||
struct fp_dscv_dev *ddev = NULL;
|
struct fp_dscv_dev *ddev = NULL;
|
||||||
struct fp_dscv_dev *tmpdev;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; tmpdev = discovered_devs[i]; i++) {
|
for (i = 0; ddev = discovered_devs[i]; i++) {
|
||||||
const struct fp_driver *drv = fp_dscv_dev_get_driver(tmpdev);
|
const struct fp_driver *drv = fp_dscv_dev_get_driver(ddev);
|
||||||
printf("Found device claimed by %s driver\n",
|
printf("Found device claimed by %s driver\n",
|
||||||
fp_driver_get_full_name(drv));
|
fp_driver_get_full_name(drv));
|
||||||
return ddev;
|
return ddev;
|
||||||
|
@ -38,11 +37,49 @@ struct fp_dscv_dev *discover_device(struct fp_dscv_dev **discovered_devs)
|
||||||
return ddev;
|
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 main(void)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
int ret = 1;
|
||||||
struct fp_dscv_dev *ddev;
|
struct fp_dscv_dev *ddev;
|
||||||
struct fp_dscv_dev **discovered_devs;
|
struct fp_dscv_dev **discovered_devs;
|
||||||
|
struct fp_dev *dev;
|
||||||
|
struct fp_print_data *data;
|
||||||
|
|
||||||
r = fp_init();
|
r = fp_init();
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
@ -62,6 +99,21 @@ int main(void)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev = fp_dev_open(ddev);
|
||||||
fp_dscv_devs_free(discovered_devs);
|
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;
|
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)
|
API_EXPORTED const char *fp_driver_get_name(const struct fp_driver *drv)
|
||||||
{
|
{
|
||||||
return drv->name;
|
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;
|
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)
|
API_EXPORTED int fp_init(void)
|
||||||
{
|
{
|
||||||
usb_init();
|
usb_init();
|
||||||
|
@ -179,3 +194,4 @@ API_EXPORTED int fp_init(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ struct fp_dev {
|
||||||
const struct fp_driver *drv;
|
const struct fp_driver *drv;
|
||||||
usb_dev_handle *udev;
|
usb_dev_handle *udev;
|
||||||
void *priv;
|
void *priv;
|
||||||
|
|
||||||
|
int nr_enroll_stages;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usb_id {
|
struct usb_id {
|
||||||
|
@ -48,6 +50,8 @@ struct fp_driver {
|
||||||
/* Device operations */
|
/* Device operations */
|
||||||
int (*init)(struct fp_dev *dev);
|
int (*init)(struct fp_dev *dev);
|
||||||
void (*exit)(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;
|
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);
|
struct fp_dev *fp_dev_open(struct fp_dscv_dev *ddev);
|
||||||
void fp_dev_close(struct fp_dev *dev);
|
void fp_dev_close(struct fp_dev *dev);
|
||||||
const struct fp_driver *fp_dev_get_driver(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 */
|
/* Drivers */
|
||||||
const char *fp_driver_get_name(const struct fp_driver *drv);
|
const char *fp_driver_get_name(const struct fp_driver *drv);
|
||||||
const char *fp_driver_get_full_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 */
|
/* Data handling */
|
||||||
void fp_print_data_free(struct fp_print_data *data);
|
void fp_print_data_free(struct fp_print_data *data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue