remove imgdev abstraction from public API

Make it easier for application developers, don't have to care about this
level of abstraction which we're intending to make superfluous to them.
This commit is contained in:
Daniel Drake 2007-11-02 17:04:19 +00:00
parent fc77786e46
commit 7e6f25908b
6 changed files with 61 additions and 21 deletions

2
TODO
View file

@ -23,7 +23,7 @@ IMAGING
aes4000 doesn't work very well, maybe due to small minutia count?
PPMM parameter to get_minutiae seems to have no effect
nbis minutiae should be stored in endian-independent format
return images with standard enroll/verify calls
return images with standard enroll/verify call variants
MISC
====

View file

@ -43,7 +43,6 @@ int main(void)
struct fp_dscv_dev *ddev;
struct fp_dscv_dev **discovered_devs;
struct fp_dev *dev;
struct fp_img_dev *imgdev;
struct fp_img *img = NULL;
r = fp_init();
@ -71,16 +70,14 @@ int main(void)
exit(1);
}
imgdev = fp_dev_to_img_dev(dev);
if (!imgdev) {
fprintf(stderr, "could not get image dev, is this an imaging "
"device?\n");
if (!fp_dev_supports_imaging(dev)) {
fprintf(stderr, "this device does not have imaging capabilities.\n");
goto out_close;
}
printf("Opened device. It's now time to scan your finger.\n\n");
r = fp_imgdev_capture(imgdev, 0, &img);
r = fp_dev_img_capture(dev, 0, &img);
if (r) {
fprintf(stderr, "image capture failed, code %d\n", r);
goto out_close;

View file

@ -349,13 +349,52 @@ API_EXPORTED uint16_t fp_driver_get_driver_id(struct fp_driver *drv)
return drv->id;
}
API_EXPORTED struct fp_img_dev *fp_dev_to_img_dev(struct fp_dev *dev)
static struct fp_img_dev *dev_to_img_dev(struct fp_dev *dev)
{
if (dev->drv->type != DRIVER_IMAGING)
return NULL;
return dev->priv;
}
API_EXPORTED int fp_dev_supports_imaging(struct fp_dev *dev)
{
return dev->drv->type == DRIVER_IMAGING;
}
API_EXPORTED int fp_dev_img_capture(struct fp_dev *dev, int unconditional,
struct fp_img **image)
{
struct fp_img_dev *imgdev = dev_to_img_dev(dev);
if (!imgdev) {
fp_dbg("image capture on non-imaging device");
return -ENOTSUP;
}
return fpi_imgdev_capture(imgdev, unconditional, image);
}
API_EXPORTED int fp_dev_get_img_width(struct fp_dev *dev)
{
struct fp_img_dev *imgdev = dev_to_img_dev(dev);
if (!imgdev) {
fp_dbg("get image width for non-imaging device");
return -1;
}
return fpi_imgdev_get_img_width(imgdev);
}
API_EXPORTED int fp_dev_get_img_height(struct fp_dev *dev)
{
struct fp_img_dev *imgdev = dev_to_img_dev(dev);
if (!imgdev) {
fp_dbg("get image height for non-imaging device");
return -1;
}
return fpi_imgdev_get_img_height(imgdev);
}
API_EXPORTED int fp_enroll_finger(struct fp_dev *dev,
struct fp_print_data **print_data)
{

View file

@ -82,6 +82,11 @@ struct fp_img_dev {
void *priv;
};
int fpi_imgdev_capture(struct fp_img_dev *imgdev, int unconditional,
struct fp_img **image);
int fpi_imgdev_get_img_width(struct fp_img_dev *imgdev);
int fpi_imgdev_get_img_height(struct fp_img_dev *imgdev);
struct usb_id {
uint16_t vendor;
uint16_t product;

View file

@ -80,11 +80,16 @@ struct fp_dev *fp_dev_open(struct fp_dscv_dev *ddev);
void fp_dev_close(struct fp_dev *dev);
struct fp_driver *fp_dev_get_driver(struct fp_dev *dev);
int fp_dev_get_nr_enroll_stages(struct fp_dev *dev);
struct fp_img_dev *fp_dev_to_img_dev(struct fp_dev *dev);
uint32_t fp_dev_get_devtype(struct fp_dev *dev);
int fp_dev_supports_print_data(struct fp_dev *dev, struct fp_print_data *data);
int fp_dev_supports_dscv_print(struct fp_dev *dev, struct fp_dscv_print *print);
int fp_dev_supports_imaging(struct fp_dev *dev);
int fp_dev_img_capture(struct fp_dev *dev, int unconditional,
struct fp_img **image);
int fp_dev_get_img_width(struct fp_dev *dev);
int fp_dev_get_img_height(struct fp_dev *dev);
/* Enrollment */
enum fp_enroll_result {
FP_ENROLL_COMPLETE = 1,
@ -123,12 +128,6 @@ struct fp_print_data *fp_print_data_from_data(unsigned char *buf,
uint16_t fp_print_data_get_driver_id(struct fp_print_data *data);
uint32_t fp_print_data_get_devtype(struct fp_print_data *data);
/* Imaging devices */
int fp_imgdev_capture(struct fp_img_dev *imgdev, int unconditional,
struct fp_img **image);
int fp_imgdev_get_img_width(struct fp_img_dev *imgdev);
int fp_imgdev_get_img_height(struct fp_img_dev *imgdev);
/* Image handling */
int fp_img_get_height(struct fp_img *img);
int fp_img_get_width(struct fp_img *img);

View file

@ -58,22 +58,22 @@ static void img_dev_exit(struct fp_dev *dev)
g_free(imgdev);
}
API_EXPORTED int fp_imgdev_get_img_width(struct fp_img_dev *imgdev)
int fpi_imgdev_get_img_width(struct fp_img_dev *imgdev)
{
struct fp_driver *drv = imgdev->dev->drv;
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
return imgdrv->img_width;
}
API_EXPORTED int fp_imgdev_get_img_height(struct fp_img_dev *imgdev)
int fpi_imgdev_get_img_height(struct fp_img_dev *imgdev)
{
struct fp_driver *drv = imgdev->dev->drv;
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
return imgdrv->img_height;
}
API_EXPORTED int fp_imgdev_capture(struct fp_img_dev *imgdev,
int unconditional, struct fp_img **image)
int fpi_imgdev_capture(struct fp_img_dev *imgdev, int unconditional,
struct fp_img **image)
{
struct fp_driver *drv = imgdev->dev->drv;
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
@ -151,7 +151,7 @@ int img_dev_enroll(struct fp_dev *dev, gboolean initial, int stage,
/* FIXME: convert to 3-stage enroll mechanism, where we scan 3 prints,
* use NFIQ to pick the best one, and discard the others */
r = fp_imgdev_capture(imgdev, 0, &img);
r = fpi_imgdev_capture(imgdev, 0, &img);
if (r)
return r;
@ -178,7 +178,7 @@ static int img_dev_verify(struct fp_dev *dev,
struct fp_print_data *print;
int r;
r = fp_imgdev_capture(imgdev, 0, &img);
r = fpi_imgdev_capture(imgdev, 0, &img);
if (r)
return r;