Compare commits

...

1 Commits

Author SHA1 Message Date
Benjamin Berg
2a9ad74ec4 print: Reject enroll images that can't be matched
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).
2022-05-17 19:16:32 +00:00
3 changed files with 22 additions and 5 deletions

View File

@@ -277,7 +277,7 @@ fpi_image_device_minutiae_detected (GObject *source_object, GAsyncResult *res, g
{ {
print = fp_print_new (device); print = fp_print_new (device);
fpi_print_set_type (print, FPI_PRINT_NBIS); 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); g_clear_object (&print);

View File

@@ -154,11 +154,14 @@ minutiae_to_xyt (struct fp_minutiae *minutiae,
gboolean gboolean
fpi_print_add_from_image (FpPrint *print, fpi_print_add_from_image (FpPrint *print,
FpImage *image, FpImage *image,
gint bz3_threshold,
GError **error) GError **error)
{ {
g_autofree struct xyt_struct *xyt = NULL;
GPtrArray *minutiae; GPtrArray *minutiae;
struct fp_minutiae _minutiae; struct fp_minutiae _minutiae;
struct xyt_struct *xyt; gint probe_len;
gint score;
if (print->type != FPI_PRINT_NBIS || !image) if (print->type != FPI_PRINT_NBIS || !image)
{ {
@@ -173,8 +176,8 @@ fpi_print_add_from_image (FpPrint *print,
if (!minutiae || minutiae->len == 0) if (!minutiae || minutiae->len == 0)
{ {
g_set_error (error, g_set_error (error,
G_IO_ERROR, FP_DEVICE_RETRY,
G_IO_ERROR_INVALID_DATA, FP_DEVICE_RETRY_GENERAL,
"No minutiae found in image or not yet detected!"); "No minutiae found in image or not yet detected!");
return FALSE; return FALSE;
} }
@@ -185,7 +188,20 @@ fpi_print_add_from_image (FpPrint *print,
xyt = g_new0 (struct xyt_struct, 1); xyt = g_new0 (struct xyt_struct, 1);
minutiae_to_xyt (&_minutiae, image->width, image->height, xyt); 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); g_clear_object (&print->image);
print->image = g_object_ref (image); print->image = g_object_ref (image);

View File

@@ -40,6 +40,7 @@ void fpi_print_set_device_stored (FpPrint *print,
gboolean fpi_print_add_from_image (FpPrint *print, gboolean fpi_print_add_from_image (FpPrint *print,
FpImage *image, FpImage *image,
gint bz3_threshold,
GError **error); GError **error);
FpiMatchResult fpi_print_bz3_match (FpPrint * template, FpiMatchResult fpi_print_bz3_match (FpPrint * template,