summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2022-05-06 11:37:38 +0200
committerBenjamin Berg <benjamin@sipsolutions.net>2022-05-17 19:16:32 +0000
commit2a9ad74ec4af89ce8f34a2d6059b7710bf70ca08 (patch)
tree31133c6df369f3b7bea00f268dfc7ecbac7342bc
parent56ae75d2b240da9d13cbb945e4d93f99b25669d0 (diff)
print: Reject enroll images that can't be matchedbenzea/self-match-check
If the score of a print matching itself is too low to match, then reject it. It can never match and it is therefore completely useless. Also change this into a non-fatal error, the user is free to retry the enroll step in the hope that more minutiae is found (e.g. longer swipe).
-rw-r--r--libfprint/fpi-image-device.c2
-rw-r--r--libfprint/fpi-print.c24
-rw-r--r--libfprint/fpi-print.h1
3 files changed, 22 insertions, 5 deletions
diff --git a/libfprint/fpi-image-device.c b/libfprint/fpi-image-device.c
index 64ea340..a272bc6 100644
--- a/libfprint/fpi-image-device.c
+++ b/libfprint/fpi-image-device.c
@@ -277,7 +277,7 @@ fpi_image_device_minutiae_detected (GObject *source_object, GAsyncResult *res, g
{
print = fp_print_new (device);
fpi_print_set_type (print, FPI_PRINT_NBIS);
- if (!fpi_print_add_from_image (print, image, &error))
+ if (!fpi_print_add_from_image (print, image, priv->bz3_threshold, &error))
{
g_clear_object (&print);
diff --git a/libfprint/fpi-print.c b/libfprint/fpi-print.c
index 16877b8..fa1a185 100644
--- a/libfprint/fpi-print.c
+++ b/libfprint/fpi-print.c
@@ -154,11 +154,14 @@ minutiae_to_xyt (struct fp_minutiae *minutiae,
gboolean
fpi_print_add_from_image (FpPrint *print,
FpImage *image,
+ gint bz3_threshold,
GError **error)
{
+ g_autofree struct xyt_struct *xyt = NULL;
GPtrArray *minutiae;
struct fp_minutiae _minutiae;
- struct xyt_struct *xyt;
+ gint probe_len;
+ gint score;
if (print->type != FPI_PRINT_NBIS || !image)
{
@@ -173,8 +176,8 @@ fpi_print_add_from_image (FpPrint *print,
if (!minutiae || minutiae->len == 0)
{
g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_INVALID_DATA,
+ FP_DEVICE_RETRY,
+ FP_DEVICE_RETRY_GENERAL,
"No minutiae found in image or not yet detected!");
return FALSE;
}
@@ -185,7 +188,20 @@ fpi_print_add_from_image (FpPrint *print,
xyt = g_new0 (struct xyt_struct, 1);
minutiae_to_xyt (&_minutiae, image->width, image->height, xyt);
- g_ptr_array_add (print->prints, xyt);
+
+ probe_len = bozorth_probe_init (xyt);
+ score = bozorth_to_gallery (probe_len, xyt, xyt);
+ fp_dbg ("self-match score %d/%d", score, bz3_threshold);
+ if (score <= bz3_threshold)
+ {
+ g_set_error (error,
+ FP_DEVICE_RETRY,
+ FP_DEVICE_RETRY_GENERAL,
+ "Not enough minutiae to generate a match!");
+ return FPI_MATCH_SUCCESS;
+ }
+
+ g_ptr_array_add (print->prints, g_steal_pointer (&xyt));
g_clear_object (&print->image);
print->image = g_object_ref (image);
diff --git a/libfprint/fpi-print.h b/libfprint/fpi-print.h
index fb38809..c29cb38 100644
--- a/libfprint/fpi-print.h
+++ b/libfprint/fpi-print.h
@@ -40,6 +40,7 @@ void fpi_print_set_device_stored (FpPrint *print,
gboolean fpi_print_add_from_image (FpPrint *print,
FpImage *image,
+ gint bz3_threshold,
GError **error);
FpiMatchResult fpi_print_bz3_match (FpPrint * template,