From 887e0e6acf8767c1f3bf571fc1ef8f5223c4c33b Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Mon, 19 Nov 2007 00:27:27 +0000 Subject: [PATCH] Add API to access minutiae --- libfprint/fp_internal.h | 15 ------------- libfprint/fprint.h | 18 ++++++++++++++++ libfprint/img.c | 48 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 16 deletions(-) diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h index 52ea98dd..5e6f15f2 100644 --- a/libfprint/fp_internal.h +++ b/libfprint/fp_internal.h @@ -189,21 +189,6 @@ gboolean fpi_print_data_compatible(uint16_t driver_id1, uint32_t devtype1, enum fp_print_data_type type1, uint16_t driver_id2, uint32_t devtype2, enum fp_print_data_type type2); -struct fp_minutia { - int x; - int y; - int ex; - int ey; - int direction; - double reliability; - int type; - int appearing; - int feature_id; - int *nbrs; - int *ridge_counts; - int num_nbrs; -}; - struct fp_minutiae { int alloc; int num; diff --git a/libfprint/fprint.h b/libfprint/fprint.h index 8eccd03f..20f05453 100644 --- a/libfprint/fprint.h +++ b/libfprint/fprint.h @@ -207,12 +207,30 @@ 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); /* Image handling */ + +/** \ingroup img */ +struct fp_minutia { + int x; + int y; + int ex; + int ey; + int direction; + double reliability; + int type; + int appearing; + int feature_id; + int *nbrs; + int *ridge_counts; + int num_nbrs; +}; + int fp_img_get_height(struct fp_img *img); int fp_img_get_width(struct fp_img *img); unsigned char *fp_img_get_data(struct fp_img *img); int fp_img_save_to_file(struct fp_img *img, char *path); void fp_img_standardize(struct fp_img *img); struct fp_img *fp_img_binarize(struct fp_img *img); +struct fp_minutia **fp_img_get_minutiae(struct fp_img *img, int *nr_minutiae); void fp_img_free(struct fp_img *img); /* Library */ diff --git a/libfprint/img.c b/libfprint/img.c index d579a63d..c8df4b22 100644 --- a/libfprint/img.c +++ b/libfprint/img.c @@ -398,8 +398,10 @@ API_EXPORTED struct fp_img *fp_img_binarize(struct fp_img *img) int r = fpi_img_detect_minutiae(img); if (r < 0) return NULL; - if (!img->binarized) + if (!img->binarized) { fp_err("no minutiae after successful detection?"); + return NULL; + } } ret = fpi_img_new(imgsize); @@ -410,3 +412,47 @@ API_EXPORTED struct fp_img *fp_img_binarize(struct fp_img *img) return ret; } +/** \ingroup img + * Get a list of minutiae detected in an image. A minutia point is a feature + * detected on a fingerprint, typically where ridges end or split. + * libfprint's image processing code relies upon comparing sets of minutiae, + * so accurate placement of minutia points is critical for good imaging + * performance. + * + * The image must have been \ref img_std "standardized" otherwise this function + * will fail. + * + * You cannot pass a binarized image to this function. Instead, pass the + * original image. + * + * Returns a list of pointers to minutiae, where the list is of length + * indicated in the nr_minutiae output parameter. The returned list is only + * valid while the parent image has not been freed, and the minutiae data + * must not be modified or freed. + * + * \param img a standardized image + * \param nr_minutiae an output location to store minutiae list length + * \returns a list of minutiae points. Must not be modified or freed. + */ +API_EXPORTED struct fp_minutia **fp_img_get_minutiae(struct fp_img *img, + int *nr_minutiae) +{ + if (img->flags & FP_IMG_BINARIZED_FORM) { + fp_err("image is binarized"); + return NULL; + } + + if (!img->minutiae) { + int r = fpi_img_detect_minutiae(img); + if (r < 0) + return NULL; + if (!img->minutiae) { + fp_err("no minutiae after successful detection?"); + return NULL; + } + } + + *nr_minutiae = img->minutiae->num; + return img->minutiae->list; +} +