Wed, 26 Jan 2011 17:55:21 +0200 було написано Hugo "Bonstra" Grostabussiat  
<dw23.de...@gmail.com>:

> On 01/26/2011 14:31, Николай Шатохин wrote:
>> Wed, 26 Jan 2011 12:12:40 +0200 було написано Hugo "Bonstra"
>> Grostabussiat <dw23.de...@gmail.com>:
>>
>>> On 01/26/2011 03:16, Николай Шатохин wrote:
>>>> I need to compare two fingerprint scans saved to disk (it's need for  
>>>> my
>>>> web-auth system which i'm developing - one image will be stored on
>>>> server,
>>>> second will be send by user, encrypted of course). Do libfprint allows
>>>> this? If no, what function I can modify to allow this?
>>> The code in enroll.c and verify.c in examples/ directory could be a  
>>> good
>>> start. However, libfprint doesn't allow to compare directly two images
>>> stored on disk, you'll need to call the internal function
>>> fpi_img_compare_print_data() (declared in fp_internal.h) to do that.
>>>
>>> Regards.
>> What is the print data? It contains image?
> fp_print_data is a structure which contains data about scanned
> fingerprint, data is either NBIS minutiae or raw device data, but not an
> image. If you want to match two images, you'll have to extract minutiae
> from both of them and compare these together.
> libfprint uses NBIS library to extract and compare minutiae, however it
> doesn't provide an interface for this unless you use internal functions.
> If doing so isn't a problem for you, your program may follow this  
> pattern:
> For image 1:
>   img1 = fpi_img_new (size_of_image1_data)
>   img1.width = width_for_image1
>   img1.height = width_for_image1
>   fpi_img_detect_minutiae (img1)
> Do the same for image 2, and once you got minutiae for both images:
>   match_score = fpi_img_compare_print_data (&img1, &img2)
>   if (match_score > BOZORTH3_DEFAULT_THRESHOLD) succeed();
>   else fail();
>
> All fpi_xxx function are declared in fp_internal.h, fpi_img_xxx
> functions are defined in img.c.
>
> Hope this helps.
> Regards.

I wrote simple source code. I try understand how to compare two  
fingerprint from files. I cut pieces and attempted to create program, that  
will compare two fprint_datas.
But I have some errors:


robotex@robotex-laptop:~/sources/fprint_examples$ gcc  
load_form_disk_and_verify.c -Inbis/include `pkg-config --cflags --libs  
glib-2.0 libfprint`
load_form_disk_and_verify.c: In function ‘fpi_img_compare_print_data’:
load_form_disk_and_verify.c:18: error: dereferencing pointer to incomplete  
type
load_form_disk_and_verify.c:19: error: dereferencing pointer to incomplete  
type
load_form_disk_and_verify.c:23: error: dereferencing pointer to incomplete  
type
load_form_disk_and_verify.c:24: error: dereferencing pointer to incomplete  
type

What did I do wrong?

Source code are:


#include <stdio.h>
#include <libfprint/fprint.h>

#include <glib.h>
#include <glib/gstdio.h>

#include "nbis/include/bozorth.h"

enum fp_print_data_type {
        PRINT_DATA_RAW = 0, /* memset-imposed default */
        PRINT_DATA_NBIS_MINUTIAE,
};

int fpi_img_compare_print_data(struct fp_print_data *enrolled_print,
        struct fp_print_data *new_print)
{
        struct xyt_struct *gstruct = (struct xyt_struct *) enrolled_print->data;
        struct xyt_struct *pstruct = (struct xyt_struct *) new_print->data;
        GTimer *timer;
        int r;

        if (enrolled_print->type != PRINT_DATA_NBIS_MINUTIAE ||
                        new_print->type != PRINT_DATA_NBIS_MINUTIAE) {
                //fp_err("invalid print format");
                return -1;
        }

        timer = g_timer_new();
        r = bozorth_main(pstruct, gstruct);
        g_timer_stop(timer);
        //fp_dbg("bozorth processing took %f seconds, score=%d",
        //      g_timer_elapsed(timer, NULL), r);
        g_timer_destroy(timer);

        return r;
}

static int load_from_file(char *path, struct fp_print_data **data)
{
        gsize length;
        gchar *contents;
        GError *err = NULL;
        struct fp_print_data *fdata;

        //fp_dbg("from %s", path);
        g_file_get_contents(path, &contents, &length, &err);
        if (err) {
                int r = err->code;
                //fp_err("%s load failed: %s", path, err->message);
                g_error_free(err);
                /* FIXME interpret more error codes */
                if (r == G_FILE_ERROR_NOENT)
                        return -1;
                else
                        return r;
        }

        fdata = fp_print_data_from_data(contents, length);
        g_free(contents);
        if (!fdata)
                return -2;
        *data = fdata;
        return 0;
}

int fp_print_data_load_from_file(struct fp_dev *dev,
        gchar *path, struct fp_print_data **data)
{
        struct fp_print_data *fdata;
        int r;

        r = load_from_file(path, &fdata);

        if (r)
                return r;

        if (!fp_dev_supports_print_data(dev, fdata)) {
                //fp_err("print data is not compatible!");
                fp_print_data_free(fdata);
                return -1;;
        }

        *data = fdata;
        return 0;
}

int main(int argc, char * argv[]) {
        struct fp_dscv_dev ** discv_devs = NULL; /* list of scanners */
        struct fp_dscv_dev * using_dev = NULL; /* using device */
        struct fp_dev * dev = NULL;
        struct fp_print_data * print_data = NULL; /* fingerprint from base */
        struct fp_print_data * print_image = NULL; /* fingerprint from file */
        int verify_retval = 0;
        gchar *path;

        /* init library fprint */
        if (fp_init()) {
                fprintf(stderr, "Cannit init fprint library!\n");
                return 1;
        }

        // get list of devices
        discv_devs = fp_discover_devs();
        if (!discv_devs) {
                fprintf(stderr, "Cannot discover any fingerprint device!\n");
                fp_exit();
                return 1;
        }

        // use first found device and print driver's name
        using_dev = discv_devs[0];
        printf("Found device using %s driver.\n",  
fp_driver_get_full_name(fp_dscv_dev_get_driver(using_dev)));
        if ((dev = fp_dev_open(using_dev)) == NULL) {
                fprintf(stderr, "Could not open device\n");
                fp_exit();
                return 1;
        }

        /* Load finger print from base */
        printf("Loading previously scanned right index fingerprint\n");
        if (fp_print_data_load(dev, RIGHT_INDEX, &print_data)) {
                fprintf(stderr, "Failed to load previously saved 
fingerprint\n");
                fp_dev_close(dev);
                fp_exit();
                return 1;
        }
        
        /* Load fingerprint from file */
        printf("Loading new right index fingerprint\n");
        if (fp_print_data_load_from_file(dev, "7", &print_image)) {
                fprintf(stderr, "Failed to load new fingerprint\n");
                fp_dev_close(dev);
                fp_exit();
                return 1;
        }

        // comparing
        fprintf(stderr, "%d\n", fpi_img_compare_print_data(print_data,  
print_image));


        // free resources
        
        fp_print_data_free(print_data);
        fp_dev_close(dev);
        fp_exit();

        return 0;
}



-- 
За використання революційного клієнта електронної пошти Opera:  
http://www.opera.com/mail/
_______________________________________________
fprint mailing list
fprint@reactivated.net
http://lists.reactivated.net/mailman/listinfo/fprint

Reply via email to