./0000755000175000017500000000000011104426331010520 5ustar dererkdererk./src/0000755000175000017500000000000011104426331011307 5ustar dererkdererk./src/img.c0000644000175000017500000000210011104426331012220 0ustar dererkdererk/* * fprint_demo: Demonstration of libfprint's capabilities * Copyright (C) 2007 Daniel Drake * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include "fprint_demo.h" static GtkWidget *iwin_create(void) { return gtk_label_new("Not implemented yet."); } struct fpd_tab img_tab = { .name = "Image capture", .create = iwin_create, }; ./src/Makefile.am0000644000175000017500000000033311104426331013342 0ustar dererkdererkbin_PROGRAMS = fprint_demo fprint_demo_SOURCES = main.c enroll.c img.c verify.c identify.c fprint_demo.h fprint_demo_LDADD = $(FPRINT_LIBS) $(GTK_LIBS) fprint_demo_CFLAGS = $(AM_CFLAGS) $(FPRINT_CFLAGS) $(GTK_CFLAGS) ./src/verify.c0000644000175000017500000003714711104426331012773 0ustar dererkdererk/* * fprint_demo: Demonstration of libfprint's capabilities * Copyright (C) 2007-2008 Daniel Drake * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include "fprint_demo.h" static GtkWidget *vwin_verify_img; static GtkWidget *vwin_fingcombo; static GtkListStore *vwin_fingmodel; static GtkWidget *vwin_vfy_status; static GtkWidget *vwin_vfy_button; static GtkWidget *vwin_non_img_label; static GtkWidget *vwin_radio_normal; static GtkWidget *vwin_radio_bin; static GtkWidget *vwin_img_save_btn; static GtkWidget *vwin_ctrl_frame; static GtkWidget *vwin_show_minutiae; static GtkWidget *vwin_minutiae_cnt; static struct fp_img *img_normal = NULL; static struct fp_img *img_bin = NULL; static struct fp_print_data *enroll_data = NULL; static void vwin_vfy_status_no_print(void) { gtk_label_set_markup(GTK_LABEL(vwin_vfy_status), "Status: No prints detected for this device."); gtk_widget_set_sensitive(vwin_vfy_button, FALSE); } static void vwin_fingcombo_select_first(void) { GtkTreeIter iter; if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(vwin_fingmodel), &iter)) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(vwin_fingcombo), &iter); else vwin_vfy_status_no_print(); } static void vwin_clear(void) { fp_img_free(img_normal); img_normal = NULL; fp_img_free(img_bin); img_bin = NULL; fp_print_data_free(enroll_data); enroll_data = NULL; gtk_image_clear(GTK_IMAGE(vwin_verify_img)); gtk_widget_set_sensitive(vwin_img_save_btn, FALSE); gtk_list_store_clear(GTK_LIST_STORE(vwin_fingmodel)); gtk_label_set_text(GTK_LABEL(vwin_vfy_status), NULL); gtk_label_set_text(GTK_LABEL(vwin_minutiae_cnt), NULL); gtk_widget_set_sensitive(vwin_fingcombo, FALSE); gtk_widget_set_sensitive(vwin_vfy_button, FALSE); } enum fingcombo_cols { FC_COL_PRINT, FC_COL_FINGNUM, FC_COL_FINGSTR, }; static void vwin_refresh(void) { struct fp_dscv_print *print; GtkTreeIter iter; int orig_fnum = -1; int i = 0; int fnum; /* find and remember currently selected finger */ if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(vwin_fingcombo), &iter)) { gtk_tree_model_get(GTK_TREE_MODEL(vwin_fingmodel), &iter, FC_COL_FINGNUM, &orig_fnum, -1); } /* re-populate list */ gtk_list_store_clear(GTK_LIST_STORE(vwin_fingmodel)); while ((print = fp_dscv_prints[i++])) { if (!fp_dev_supports_dscv_print(fpdev, print)) continue; fnum = fp_dscv_print_get_finger(print); gtk_list_store_append(vwin_fingmodel, &iter); gtk_list_store_set(vwin_fingmodel, &iter, FC_COL_PRINT, print, FC_COL_FINGSTR, fingerstr(fnum), FC_COL_FINGNUM, fnum, -1); } /* try and select original again */ if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(vwin_fingmodel), &iter) || orig_fnum == -1) { vwin_fingcombo_select_first(); return; } do { gtk_tree_model_get(GTK_TREE_MODEL(vwin_fingmodel), &iter, FC_COL_FINGNUM, &fnum, -1); if (fnum == orig_fnum) { gtk_combo_box_set_active_iter(GTK_COMBO_BOX(vwin_fingcombo), &iter); return; } } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(vwin_fingmodel), &iter)); /* could not find original -- it may have been deleted */ vwin_fingcombo_select_first(); } static void vwin_activate_dev(void) { struct fp_dscv_print *print; int i = 0; g_assert(fpdev); g_assert(fp_dscv_prints); while ((print = fp_dscv_prints[i++])) { GtkTreeIter iter; int fnum; if (!fp_dev_supports_dscv_print(fpdev, print)) continue; fnum = fp_dscv_print_get_finger(print); gtk_list_store_append(vwin_fingmodel, &iter); gtk_list_store_set(vwin_fingmodel, &iter, FC_COL_PRINT, print, FC_COL_FINGSTR, fingerstr(fnum), FC_COL_FINGNUM, fnum, -1); } gtk_widget_set_sensitive(vwin_fingcombo, TRUE); vwin_fingcombo_select_first(); if (fp_dev_supports_imaging(fpdev)) { int width = fp_dev_get_img_width(fpdev); int height = fp_dev_get_img_height(fpdev); gtk_widget_set_size_request(vwin_verify_img, (width == 0) ? 192 : width, (height == 0) ? 192 : height); gtk_widget_hide(vwin_non_img_label); gtk_widget_show(vwin_verify_img); gtk_widget_set_sensitive(vwin_ctrl_frame, TRUE); } else { gtk_widget_show(vwin_non_img_label); gtk_widget_hide(vwin_verify_img); gtk_widget_set_sensitive(vwin_ctrl_frame, FALSE); } } static void vwin_vfy_status_print_loaded(int status) { if (status == 0) { gtk_label_set_markup(GTK_LABEL(vwin_vfy_status), "Status: Ready for verify scan."); gtk_widget_set_sensitive(vwin_vfy_button, TRUE); } else { gchar *msg = g_strdup_printf("Status: Error %d, print corrupt?", status); gtk_label_set_markup(GTK_LABEL(vwin_vfy_status), msg); gtk_widget_set_sensitive(vwin_vfy_button, FALSE); g_free(msg); } } static void vwin_cb_fing_changed(GtkWidget *widget, gpointer user_data) { struct fp_dscv_print *dprint; GtkTreeIter iter; int r; fp_print_data_free(enroll_data); enroll_data = NULL; if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(vwin_fingcombo), &iter)) return; gtk_tree_model_get(GTK_TREE_MODEL(vwin_fingmodel), &iter, FC_COL_PRINT, &dprint, -1); r = fp_print_data_from_dscv_print(dprint, &enroll_data); vwin_vfy_status_print_loaded(r); } static void vwin_vfy_status_verify_result(int code) { const char *msgs[] = { [FP_VERIFY_NO_MATCH] = "Finger does not match.", [FP_VERIFY_MATCH] = "Finger matches!", [FP_VERIFY_RETRY] = "Bad scan.", [FP_VERIFY_RETRY_TOO_SHORT] = "Swipe was too short.", [FP_VERIFY_RETRY_CENTER_FINGER] = "Finger was not centered on sensor.", [FP_VERIFY_RETRY_REMOVE_FINGER] = "Bad scan, remove finger.", }; gchar *msg; if (code < 0) { msg = g_strdup_printf("Status: Scan failed, error %d", code); gtk_label_set_text(GTK_LABEL(vwin_minutiae_cnt), NULL); } else { msg = g_strdup_printf("Status: %s", msgs[code]); } gtk_label_set_markup(GTK_LABEL(vwin_vfy_status), msg); g_free(msg); } static void plot_minutiae(unsigned char *rgbdata, int width, int height, struct fp_minutia **minlist, int nr_minutiae) { int i; #define write_pixel(num) do { \ rgbdata[((num) * 3)] = 0xff; \ rgbdata[((num) * 3) + 1] = 0; \ rgbdata[((num) * 3) + 2] = 0; \ } while(0) for (i = 0; i < nr_minutiae; i++) { struct fp_minutia *min = minlist[i]; size_t pixel_offset = (min->y * width) + min->x; write_pixel(pixel_offset - 2); write_pixel(pixel_offset - 1); write_pixel(pixel_offset); write_pixel(pixel_offset + 1); write_pixel(pixel_offset + 2); write_pixel(pixel_offset - (width * 2)); write_pixel(pixel_offset - (width * 1) - 1); write_pixel(pixel_offset - (width * 1)); write_pixel(pixel_offset - (width * 1) + 1); write_pixel(pixel_offset + (width * 1) - 1); write_pixel(pixel_offset + (width * 1)); write_pixel(pixel_offset + (width * 1) + 1); write_pixel(pixel_offset + (width * 2)); } } static void vwin_img_draw(void) { struct fp_minutia **minlist; unsigned char *rgbdata; GdkPixbuf *pixbuf; gchar *tmp; int nr_minutiae; int width; int height; if (!img_normal || !img_bin) return; minlist = fp_img_get_minutiae(img_normal, &nr_minutiae); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vwin_radio_normal))) rgbdata = img_to_rgbdata(img_normal); else rgbdata = img_to_rgbdata(img_bin); width = fp_img_get_width(img_normal); height = fp_img_get_height(img_normal); gtk_widget_set_size_request(vwin_verify_img, width, height); tmp = g_strdup_printf("Detected %d minutiae.", nr_minutiae); gtk_label_set_text(GTK_LABEL(vwin_minutiae_cnt), tmp); g_free(tmp); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vwin_show_minutiae))) plot_minutiae(rgbdata, width, height, minlist, nr_minutiae); pixbuf = gdk_pixbuf_new_from_data(rgbdata, GDK_COLORSPACE_RGB, FALSE, 8, width, height, width * 3, pixbuf_destroy, NULL); gtk_image_set_from_pixbuf(GTK_IMAGE(vwin_verify_img), pixbuf); g_object_unref(pixbuf); gtk_widget_set_sensitive(vwin_img_save_btn, TRUE); } static void vwin_cb_imgfmt_toggled(GtkWidget *widget, gpointer data) { vwin_img_draw(); } static void verify_stopped_cb(struct fp_dev *dev, void *user_data) { gtk_widget_destroy(GTK_WIDGET(user_data)); } static void verify_cb(struct fp_dev *dev, int result, struct fp_img *img, void *user_data) { GtkWidget *dialog; int r; destroy_scan_finger_dialog(GTK_WIDGET(user_data)); vwin_vfy_status_verify_result(result); fp_img_free(img_normal); img_normal = NULL; fp_img_free(img_bin); img_bin = NULL; if (img) { img_normal = img; img_bin = fp_img_binarize(img); vwin_img_draw(); } dialog = run_please_wait_dialog("Ending verification..."); r = fp_async_verify_stop(dev, verify_stopped_cb, dialog); if (r < 0) gtk_widget_destroy(dialog); } static void scan_finger_response(GtkWidget *dialog, gint arg, gpointer user_data) { int r; destroy_scan_finger_dialog(dialog); dialog = run_please_wait_dialog("Ending verification..."); r = fp_async_verify_stop(fpdev, verify_stopped_cb, dialog); if (r < 0) gtk_widget_destroy(dialog); } static void vwin_cb_verify(GtkWidget *widget, gpointer user_data) { GtkWidget *dialog; int r; gtk_widget_set_sensitive(vwin_img_save_btn, FALSE); dialog = create_scan_finger_dialog(); r = fp_async_verify_start(fpdev, enroll_data, verify_cb, dialog); if (r < 0) { destroy_scan_finger_dialog(dialog); dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(mwin_window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Could not start verification, error %d", r, NULL); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); return; } g_signal_connect(dialog, "response", G_CALLBACK(scan_finger_response), NULL); run_scan_finger_dialog(dialog); } static void vwin_cb_img_save(GtkWidget *widget, gpointer user_data) { GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(vwin_verify_img)); GtkWidget *dialog; gchar *filename; GError *error = NULL; g_assert(pixbuf); dialog = gtk_file_chooser_dialog_new("Save Image", GTK_WINDOW(mwin_window), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "fingerprint.png"); if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) { gtk_widget_destroy(dialog); return; } filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); gtk_widget_destroy(dialog); if (!gdk_pixbuf_save(pixbuf, filename, "png", &error, NULL)) { dialog = gtk_message_dialog_new(GTK_WINDOW(mwin_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, error->message); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); g_error_free(error); } g_free(filename); } static gint fing_sort(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data) { int num1, num2; gtk_tree_model_get(model, a, FC_COL_FINGNUM, &num1, -1); gtk_tree_model_get(model, b, FC_COL_FINGNUM, &num2, -1); return num1 - num2; } static GtkWidget *vwin_create(void) { GtkCellRenderer *renderer; GtkWidget *ui_vbox; GtkWidget *label, *vfy_vbox, *vfy_frame, *scan_frame, *img_vbox; GtkWidget *vwin_ctrl_vbox; GtkWidget *vwin_main_hbox; vwin_main_hbox = gtk_hbox_new(FALSE, 1); /* Image frame */ scan_frame = gtk_frame_new("Scanned Image"); gtk_box_pack_start(GTK_BOX(vwin_main_hbox), scan_frame, TRUE, TRUE, 0); /* Image vbox */ img_vbox = gtk_vbox_new(FALSE, 1); gtk_container_add(GTK_CONTAINER(scan_frame), img_vbox); /* Image */ vwin_verify_img = gtk_image_new(); gtk_box_pack_start(GTK_BOX(img_vbox), vwin_verify_img, TRUE, FALSE, 0); /* Non-imaging device */ vwin_non_img_label = gtk_label_new("This device does not have imaging " "capabilities, no images will be displayed."); gtk_box_pack_start_defaults(GTK_BOX(img_vbox), vwin_non_img_label); /* vbox for verification status and image control frames */ ui_vbox = gtk_vbox_new(FALSE, 1); gtk_box_pack_end(GTK_BOX(vwin_main_hbox), ui_vbox, FALSE, FALSE, 0); /* Verification status */ vfy_frame = gtk_frame_new("Verification"); gtk_box_pack_start_defaults(GTK_BOX(ui_vbox), vfy_frame); vfy_vbox = gtk_vbox_new(FALSE, 1); gtk_container_add(GTK_CONTAINER(vfy_frame), vfy_vbox); /* Discovered prints list */ label = gtk_label_new("Select a finger to verify:"); gtk_box_pack_start(GTK_BOX(vfy_vbox), label, FALSE, FALSE, 0); vwin_fingmodel = gtk_list_store_new(3, G_TYPE_POINTER, G_TYPE_INT, G_TYPE_STRING); vwin_fingcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(vwin_fingmodel)); g_signal_connect(G_OBJECT(vwin_fingcombo), "changed", G_CALLBACK(vwin_cb_fing_changed), NULL); gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(vwin_fingmodel), 0, fing_sort, NULL, NULL); gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(vwin_fingmodel), 0, GTK_SORT_ASCENDING); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(vwin_fingcombo), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(vwin_fingcombo), renderer, "text", FC_COL_FINGSTR, NULL); gtk_box_pack_start(GTK_BOX(vfy_vbox), vwin_fingcombo, FALSE, FALSE, 0); /* Verify button */ vwin_vfy_button = gtk_button_new_with_label("Verify"); g_signal_connect(G_OBJECT(vwin_vfy_button), "clicked", G_CALLBACK(vwin_cb_verify), NULL); gtk_box_pack_start(GTK_BOX(vfy_vbox), vwin_vfy_button, FALSE, FALSE, 0); /* Verify status */ vwin_vfy_status = gtk_label_new(NULL); gtk_box_pack_start(GTK_BOX(vfy_vbox), vwin_vfy_status, FALSE, FALSE, 0); /* Minutiae count */ vwin_minutiae_cnt = gtk_label_new(NULL); gtk_box_pack_start(GTK_BOX(vfy_vbox), vwin_minutiae_cnt, FALSE, FALSE, 0); /* Image controls frame */ vwin_ctrl_frame = gtk_frame_new("Image control"); gtk_box_pack_end_defaults(GTK_BOX(ui_vbox), vwin_ctrl_frame); vwin_ctrl_vbox = gtk_vbox_new(FALSE, 1); gtk_container_add(GTK_CONTAINER(vwin_ctrl_frame), vwin_ctrl_vbox); /* Image format radio buttons */ vwin_radio_normal = gtk_radio_button_new_with_label(NULL, "Normal"); g_signal_connect(G_OBJECT(vwin_radio_normal), "toggled", G_CALLBACK(vwin_cb_imgfmt_toggled), NULL); gtk_box_pack_start(GTK_BOX(vwin_ctrl_vbox), vwin_radio_normal, FALSE, FALSE, 0); vwin_radio_bin = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(vwin_radio_normal), "Binarized"); gtk_box_pack_start(GTK_BOX(vwin_ctrl_vbox), vwin_radio_bin, FALSE, FALSE, 0); /* Minutiae plotting */ vwin_show_minutiae = gtk_check_button_new_with_label("Show minutiae"); g_signal_connect(GTK_OBJECT(vwin_show_minutiae), "toggled", G_CALLBACK(vwin_cb_imgfmt_toggled), NULL); gtk_box_pack_start(GTK_BOX(vwin_ctrl_vbox), vwin_show_minutiae, FALSE, FALSE, 0); /* Save image */ vwin_img_save_btn = gtk_button_new_from_stock(GTK_STOCK_SAVE); g_signal_connect(G_OBJECT(vwin_img_save_btn), "clicked", G_CALLBACK(vwin_cb_img_save), NULL); gtk_box_pack_end(GTK_BOX(vwin_ctrl_vbox), vwin_img_save_btn, FALSE, FALSE, 0); return vwin_main_hbox; } struct fpd_tab verify_tab = { .name = "Verify", .create = vwin_create, .activate_dev = vwin_activate_dev, .clear = vwin_clear, .refresh = vwin_refresh, }; ./src/main.c0000644000175000017500000003312111104426331012377 0ustar dererkdererk/* * fprint_demo: Demonstration of libfprint's capabilities * Copyright (C) 2007-2008 Daniel Drake * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include #include #include "fprint_demo.h" #define for_each_tab_call_op(op) do { \ int __fe_tabno; \ for (__fe_tabno = 0; __fe_tabno < G_N_ELEMENTS(tabs); __fe_tabno++) { \ const struct fpd_tab *__fe_tab = tabs[__fe_tabno]; \ if (__fe_tab->op) \ __fe_tab->op(); \ } \ } while(0); static GtkWidget *mwin_devcombo; static GtkListStore *mwin_devmodel; static GtkWidget *mwin_drvname_label; static GtkWidget *mwin_imgcapa_label; static GtkWidget *mwin_devstatus_label; static GtkWidget *mwin_notebook; struct fp_dev *fpdev = NULL; struct fp_dscv_print **fp_dscv_prints = NULL; GtkWidget *mwin_window; static const struct fpd_tab *tabs[] = { &enroll_tab, &verify_tab, &identify_tab, &img_tab, }; static void mwin_devstatus_update(char *status) { gchar *msg = g_strdup_printf("Status: %s", status); gtk_label_set_markup(GTK_LABEL(mwin_devstatus_label), msg); g_free(msg); } static void dev_open_cb(struct fp_dev *dev, int status, void *user_data) { struct fp_driver *drv; gchar *tmp; gtk_widget_destroy(GTK_WIDGET(user_data)); fpdev = dev; fp_dscv_prints = fp_discover_prints(); if (!fp_dscv_prints) { mwin_devstatus_update("Error loading enrolled prints."); /* FIXME error handling */ return; } mwin_devstatus_update("Device ready for use."); drv = fp_dev_get_driver(fpdev); tmp = g_strdup_printf("Driver: %s", fp_driver_get_name(drv)); gtk_label_set_markup(GTK_LABEL(mwin_drvname_label), tmp); g_free(tmp); if (fp_dev_supports_imaging(fpdev)) gtk_label_set_markup(GTK_LABEL(mwin_imgcapa_label), "Imaging device"); else gtk_label_set_markup(GTK_LABEL(mwin_imgcapa_label), "Non-imaging device"); for_each_tab_call_op(activate_dev); } static void mwin_cb_dev_changed(GtkWidget *widget, gpointer user_data) { GtkTreeIter iter; GtkWidget *dialog; struct fp_dscv_dev *ddev; int r; for_each_tab_call_op(clear); if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(mwin_devcombo), &iter)) { mwin_devstatus_update("No devices found."); return; } gtk_tree_model_get(GTK_TREE_MODEL(mwin_devmodel), &iter, 1, &ddev, -1); fp_dscv_prints_free(fp_dscv_prints); fp_dscv_prints = NULL; fp_dev_close(fpdev); dialog = run_please_wait_dialog("Opening device..."); r = fp_async_dev_open(ddev, dev_open_cb, dialog); if (r) mwin_devstatus_update("Could not open device."); } static void mwin_cb_destroy(GtkWidget *widget, gpointer data) { gtk_main_quit(); } static GtkWidget *mwin_create_devbar(void) { GtkCellRenderer *renderer; GtkWidget *devbar_hbox, *dev_vbox, *button; /* hbox for lower and upper halves */ devbar_hbox = gtk_hbox_new(FALSE, 3); /* Device vbox */ dev_vbox = gtk_vbox_new(FALSE, 1); gtk_box_pack_start_defaults(GTK_BOX(devbar_hbox), dev_vbox); /* Device model and combo box */ mwin_devmodel = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); mwin_devcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(mwin_devmodel)); g_signal_connect(G_OBJECT(mwin_devcombo), "changed", G_CALLBACK(mwin_cb_dev_changed), NULL); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(mwin_devcombo), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(mwin_devcombo), renderer, "text", 0, NULL); gtk_box_pack_start(GTK_BOX(dev_vbox), mwin_devcombo, FALSE, FALSE, 0); /* Labels */ mwin_devstatus_label = gtk_label_new(NULL); gtk_box_pack_start_defaults(GTK_BOX(dev_vbox), mwin_devstatus_label); mwin_drvname_label = gtk_label_new(NULL); gtk_box_pack_start_defaults(GTK_BOX(dev_vbox), mwin_drvname_label); mwin_imgcapa_label = gtk_label_new(NULL); gtk_box_pack_start_defaults(GTK_BOX(dev_vbox), mwin_imgcapa_label); /* Buttons */ button = gtk_button_new_from_stock(GTK_STOCK_QUIT); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(mwin_cb_destroy), NULL); gtk_box_pack_start(GTK_BOX(devbar_hbox), button, FALSE, FALSE, 0); return devbar_hbox; } static void mwin_create(void) { GtkWidget *main_vbox; int i; /* Window */ mwin_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(mwin_window), "fprint project demo v" VERSION); g_signal_connect(G_OBJECT(mwin_window), "destroy", G_CALLBACK(mwin_cb_destroy), NULL); /* Top level vbox */ main_vbox = gtk_vbox_new(FALSE, 5); gtk_container_add(GTK_CONTAINER(mwin_window), main_vbox); /* Notebook */ mwin_notebook = gtk_notebook_new(); gtk_box_pack_start_defaults(GTK_BOX(main_vbox), mwin_notebook); for (i = 0; i < G_N_ELEMENTS(tabs); i++) { const struct fpd_tab *tab = tabs[i]; gtk_notebook_append_page(GTK_NOTEBOOK(mwin_notebook), tab->create(), gtk_label_new(tab->name)); } for_each_tab_call_op(clear); /* Device bar */ gtk_box_pack_end(GTK_BOX(main_vbox), mwin_create_devbar(), FALSE, FALSE, 0); gtk_widget_show_all(mwin_window); } static gboolean mwin_populate_devs(void) { struct fp_dscv_dev **discovered_devs; struct fp_dscv_dev *ddev; int i; discovered_devs = fp_discover_devs(); if (!discovered_devs) return FALSE; for (i = 0; (ddev = discovered_devs[i]); i++) { struct fp_driver *drv = fp_dscv_dev_get_driver(ddev); GtkTreeIter iter; gtk_list_store_append(mwin_devmodel, &iter); gtk_list_store_set(mwin_devmodel, &iter, 0, fp_driver_get_full_name(drv), 1, ddev, -1); } return TRUE; } static gboolean mwin_select_first_dev(void) { gtk_combo_box_set_active(GTK_COMBO_BOX(mwin_devcombo), 0); return TRUE; } struct fdsource { GSource source; GSList *pollfds; }; static gboolean source_prepare(GSource *source, gint *timeout) { int r; struct timeval tv; r = fp_get_next_timeout(&tv); if (r == 0) { *timeout = -1; return FALSE; } if (!timerisset(&tv)) return TRUE; *timeout = (tv.tv_sec * 1000) + (tv.tv_usec / 1000); return FALSE; } static gboolean source_check(GSource *source) { struct fdsource *_fdsource = (struct fdsource *) source; GSList *elem = _fdsource->pollfds; struct timeval tv; int r; if (!elem) return FALSE; do { GPollFD *pollfd = elem->data; if (pollfd->revents) return TRUE; } while ((elem = g_slist_next(elem))); r = fp_get_next_timeout(&tv); if (r == 1 && !timerisset(&tv)) return TRUE; return FALSE; } static gboolean source_dispatch(GSource *source, GSourceFunc callback, gpointer data) { struct timeval zerotimeout = { .tv_sec = 0, .tv_usec = 0, }; /* FIXME error handling */ fp_handle_events_timeout(&zerotimeout); /* FIXME whats the return value used for? */ return TRUE; } static void source_finalize(GSource *source) { struct fdsource *_fdsource = (struct fdsource *) source; GSList *elem = _fdsource->pollfds; if (elem) do { GPollFD *pollfd = elem->data; g_source_remove_poll((GSource *) _fdsource, pollfd); g_slice_free(GPollFD, pollfd); _fdsource->pollfds = g_slist_delete_link(_fdsource->pollfds, elem); } while ((elem = g_slist_next(elem))); g_slist_free(_fdsource->pollfds); } static GSourceFuncs sourcefuncs = { .prepare = source_prepare, .check = source_check, .dispatch = source_dispatch, .finalize = source_finalize, }; struct fdsource *fdsource = NULL; static void pollfd_add(int fd, short events) { GPollFD *pollfd = g_slice_new(GPollFD); pollfd->fd = fd; pollfd->events = 0; pollfd->revents = 0; if (events & POLLIN) pollfd->events |= G_IO_IN; if (events & POLLOUT) pollfd->events |= G_IO_OUT; fdsource->pollfds = g_slist_prepend(fdsource->pollfds, pollfd); g_source_add_poll((GSource *) fdsource, pollfd); } static void pollfd_added_cb(int fd, short events) { g_message("now monitoring fd %d", fd); pollfd_add(fd, events); } static void pollfd_removed_cb(int fd) { GSList *elem = fdsource->pollfds; g_message("no longer monitoring fd %d", fd); if (!elem) { g_warning("cannot remove from list as list is empty?"); return; } do { GPollFD *pollfd = elem->data; if (pollfd->fd != fd) continue; g_source_remove_poll((GSource *) fdsource, pollfd); g_slice_free(GPollFD, pollfd); fdsource->pollfds = g_slist_delete_link(fdsource->pollfds, elem); return; } while ((elem = g_slist_next(elem))); g_error("couldn't find fd in list\n"); } static int setup_pollfds(void) { size_t numfds; size_t i; struct fp_pollfd *fpfds; GSource *gsource = g_source_new(&sourcefuncs, sizeof(struct fdsource)); fdsource = (struct fdsource *) gsource; fdsource->pollfds = NULL; numfds = fp_get_pollfds(&fpfds); if (numfds < 0) { if (fpfds) free(fpfds); return (int) numfds; } else if (numfds > 0) { for (i = 0; i < numfds; i++) { struct fp_pollfd *fpfd = &fpfds[i]; pollfd_add(fpfd->fd, fpfd->events); } } free(fpfds); fp_set_pollfd_notifiers(pollfd_added_cb, pollfd_removed_cb); g_source_attach(gsource, NULL); return 0; } int main(int argc, char **argv) { int r; r = fp_init(); if (r < 0) return r; gtk_init(&argc, &argv); gtk_window_set_default_icon_name("fprint_demo"); r = setup_pollfds(); if (r < 0) return r; mwin_create(); mwin_populate_devs(); mwin_select_first_dev(); gtk_main(); if (fpdev) fp_dev_close(fpdev); fp_exit(); return 0; } const char *fingerstr(enum fp_finger finger) { const char *names[] = { [LEFT_THUMB] = "Left thumb", [LEFT_INDEX] = "Left index finger", [LEFT_MIDDLE] = "Left middle finger", [LEFT_RING] = "Left ring finger", [LEFT_LITTLE] = "Left little finger", [RIGHT_THUMB] = "Right thumb", [RIGHT_INDEX] = "Right index finger", [RIGHT_MIDDLE] = "Right middle finger", [RIGHT_RING] = "Right ring finger", [RIGHT_LITTLE] = "Right little finger", }; if (finger < LEFT_THUMB || finger > RIGHT_LITTLE) return "UNKNOWN"; return names[finger]; } void pixbuf_destroy(guchar *pixels, gpointer data) { g_free(pixels); } unsigned char *img_to_rgbdata(struct fp_img *img) { int size = fp_img_get_width(img) * fp_img_get_height(img); unsigned char *imgdata = fp_img_get_data(img); unsigned char *rgbdata = g_malloc(size * 3); size_t i; size_t rgb_offset = 0; for (i = 0; i < size; i++) { unsigned char pixel = imgdata[i]; rgbdata[rgb_offset++] = pixel; rgbdata[rgb_offset++] = pixel; rgbdata[rgb_offset++] = pixel; } return rgbdata; } GdkPixbuf *img_to_pixbuf(struct fp_img *img) { int width = fp_img_get_width(img); int height = fp_img_get_height(img); unsigned char *rgbdata = img_to_rgbdata(img); return gdk_pixbuf_new_from_data(rgbdata, GDK_COLORSPACE_RGB, FALSE, 8, width, height, width * 3, pixbuf_destroy, NULL); } void mwin_refresh_prints(void) { fp_dscv_prints_free(fp_dscv_prints); fp_dscv_prints = NULL; fp_dscv_prints = fp_discover_prints(); if (!fp_dscv_prints) { mwin_devstatus_update("Error loading enrolled prints."); if (fpdev) fp_dev_close(fpdev); fpdev = NULL; gtk_label_set_text(GTK_LABEL(mwin_drvname_label), NULL); gtk_label_set_text(GTK_LABEL(mwin_imgcapa_label), NULL); for_each_tab_call_op(clear); } else { for_each_tab_call_op(refresh); } } /* simple dialog to display a "Please wait" message */ GtkWidget *run_please_wait_dialog(char *msg) { GtkWidget *dlg = gtk_dialog_new(); GtkWidget *label = gtk_label_new(msg); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dlg)->vbox), label); gtk_window_set_modal(GTK_WINDOW(dlg), TRUE); gtk_widget_show_all(dlg); gtk_widget_hide(GTK_DIALOG(dlg)->action_area); return dlg; } /* create and populate a dialog with a request to scan a finger plus a cancel * button. hook onto the response signal in order to listen for cancellation. */ GtkWidget *create_scan_finger_dialog(void) { GtkWidget *dialog, *label, *progressbar; GtkWidget *vbox; dialog = gtk_dialog_new_with_buttons("Scan finger", GTK_WINDOW(mwin_window), GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); gtk_window_set_deletable(GTK_WINDOW(dialog), FALSE); vbox = GTK_DIALOG(dialog)->vbox; label = gtk_label_new("Scan your finger now"); gtk_box_pack_start_defaults(GTK_BOX(vbox), label); progressbar = gtk_progress_bar_new(); gtk_box_pack_end_defaults(GTK_BOX(vbox), progressbar); g_object_set_data(G_OBJECT(dialog), "progressbar", progressbar); return dialog; } /* timer callback to pulse the progress bar */ static gboolean scan_finger_pulse_progress(gpointer data) { GtkWidget *dialog = data; GtkWidget *progressbar = g_object_get_data(G_OBJECT(dialog), "progressbar"); if (!progressbar) return FALSE; gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progressbar)); return TRUE; } /* show a scan finger dialog */ void run_scan_finger_dialog(GtkWidget *dialog) { guint id; gtk_widget_show_all(dialog); id = gdk_threads_add_timeout(100, scan_finger_pulse_progress, dialog); g_object_set_data(G_OBJECT(dialog), "pulsesource", GUINT_TO_POINTER(id)); } /* destroy a scan finger dialog */ void destroy_scan_finger_dialog(GtkWidget *dialog) { gpointer source = g_object_get_data(G_OBJECT(dialog), "pulsesource"); if (source) g_source_remove(GPOINTER_TO_UINT(source)); gtk_widget_destroy(dialog); } ./src/enroll.c0000644000175000017500000003022011104426331012743 0ustar dererkdererk/* * fprint_demo: Demonstration of libfprint's capabilities * Copyright (C) 2007-2008 Daniel Drake * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include "fprint_demo.h" static GtkWidget *ewin_enroll_btn[RIGHT_LITTLE+1]; static GtkWidget *ewin_delete_btn[RIGHT_LITTLE+1]; static GtkWidget *ewin_status_lbl[RIGHT_LITTLE+1]; static GtkWidget *edlg_dialog; static GtkWidget *edlg_please_wait; static GtkWidget *edlg_progress_lbl; static GtkWidget *edlg_instr_lbl; static GtkWidget *edlg_progress_bar; static GtkWidget *edlg_img_hbox; static GtkWidget *edlg_last_image = NULL; static struct fp_img *edlg_last_fp_img = NULL; static struct fp_print_data *edlg_enroll_data = NULL; static int nr_enroll_stages = 0; static int enroll_stage = 0; static gboolean enroll_complete = FALSE; /* the numeric index of the finger being enrolled */ static int edlg_finger = 0; static GtkWidget *create_enroll_dialog(void) { const char *fstr = fingerstr(edlg_finger); gchar *fstr_lower = g_ascii_strdown(fstr, -1); nr_enroll_stages = fp_dev_get_nr_enroll_stages(fpdev); gchar *tmp; GtkWidget *label, *vbox; tmp = g_strdup_printf("Enroll %s", fstr_lower); edlg_dialog = gtk_dialog_new_with_buttons(tmp, GTK_WINDOW(mwin_window), GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); g_free(tmp); vbox = GTK_DIALOG(edlg_dialog)->vbox; tmp = g_strdup_printf("In order to enroll your %s you will have to " "successfully scan your finger %d time%s.", fstr_lower, nr_enroll_stages, (nr_enroll_stages == 1) ? "" : "s"); label = gtk_label_new(tmp); gtk_box_pack_start_defaults(GTK_BOX(vbox), label); g_free(fstr_lower); g_free(tmp); edlg_progress_lbl = gtk_label_new(NULL); gtk_box_pack_start_defaults(GTK_BOX(vbox), edlg_progress_lbl); tmp = g_strdup_printf("Step 1 of %d", nr_enroll_stages); gtk_label_set_markup(GTK_LABEL(edlg_progress_lbl), tmp); g_free(tmp); edlg_img_hbox = gtk_hbox_new(FALSE, 2); gtk_box_pack_start_defaults(GTK_BOX(vbox), edlg_img_hbox); edlg_progress_bar = gtk_progress_bar_new(); gtk_box_pack_start_defaults(GTK_BOX(vbox), edlg_progress_bar); g_object_set_data(G_OBJECT(edlg_dialog), "progressbar", edlg_progress_bar); edlg_instr_lbl = gtk_label_new(NULL); gtk_box_pack_start_defaults(GTK_BOX(vbox), edlg_instr_lbl); gtk_label_set_text(GTK_LABEL(edlg_instr_lbl), "Scan your finger now"); gtk_dialog_set_response_sensitive(GTK_DIALOG(edlg_dialog), GTK_RESPONSE_OK, FALSE); return edlg_dialog; } /* timeout-invoked function which pulses the progress bar */ static gboolean edlg_pulse_progress(gpointer data) { GtkWidget *dialog = data; GtkWidget *progressbar = g_object_get_data(G_OBJECT(dialog), "progressbar"); if (!progressbar) return FALSE; gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progressbar)); return TRUE; } static void run_enroll_dialog(GtkWidget *dialog) { guint id; gtk_widget_show_all(dialog); id = gdk_threads_add_timeout(100, edlg_pulse_progress, dialog); g_object_set_data(G_OBJECT(dialog), "pulsesource", GUINT_TO_POINTER(id)); } static void stop_edlg_progress_pulse(GtkWidget *dialog) { gpointer source = g_object_get_data(G_OBJECT(dialog), "pulsesource"); if (source) { g_source_remove(GPOINTER_TO_UINT(source)); g_object_set_data(G_OBJECT(dialog), "pulsesource", NULL); } } static void destroy_enroll_dialog(GtkWidget *dialog) { stop_edlg_progress_pulse(dialog); gtk_widget_destroy(dialog); } static void __enroll_stopped(int result) { if (edlg_please_wait) { gtk_widget_destroy(edlg_please_wait); edlg_please_wait = NULL; } if (!enroll_complete) return; stop_edlg_progress_pulse(edlg_dialog); if (result < 0) { GtkWidget *dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(mwin_window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Enroll failed with error %d", result, NULL); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); destroy_enroll_dialog(edlg_dialog); } else if (result == FP_ENROLL_FAIL) { gtk_progress_bar_set_text(GTK_PROGRESS_BAR(edlg_progress_bar), "Enrollment failed due to bad scan data."); gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(edlg_progress_bar), 0.0); gtk_label_set_text(GTK_LABEL(edlg_instr_lbl), "Click Cancel to " "continue."); } else if (result == FP_ENROLL_COMPLETE) { gtk_progress_bar_set_text(GTK_PROGRESS_BAR(edlg_progress_bar), "Enrollment complete!"); gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(edlg_progress_bar), 1.0); gtk_label_set_text(GTK_LABEL(edlg_instr_lbl), "Click OK to save " "and continue."); gtk_dialog_set_response_sensitive(GTK_DIALOG(edlg_dialog), GTK_RESPONSE_OK, TRUE); /* FIXME: grab focus on OK button? */ } else { g_error("unknown enroll result %d", result); } } static void enroll_stopped(struct fp_dev *dev, void *user_data) { __enroll_stopped(GPOINTER_TO_INT(user_data)); } static void edlg_cancel_enroll(int result) { int r; void *data = GINT_TO_POINTER(result); enroll_stage = -1; r = fp_async_enroll_stop(fpdev, enroll_stopped, data); if (r < 0) __enroll_stopped(result); } static void enroll_stage_cb(struct fp_dev *dev, int result, struct fp_print_data *print, struct fp_img *img, void *user_data) { gboolean free_tmp = FALSE; gchar *tmp; if (result < 0) { edlg_cancel_enroll(result); return; } if (img) { GdkPixbuf *pixbuf = img_to_pixbuf(img); GtkWidget *image = gtk_image_new_from_pixbuf(pixbuf); gtk_box_pack_start_defaults(GTK_BOX(edlg_img_hbox), image); gtk_widget_show(image); edlg_last_fp_img = img; edlg_last_image = image; g_object_unref(G_OBJECT(pixbuf)); } else { edlg_last_fp_img = NULL; edlg_last_image = NULL; } if (print) edlg_enroll_data = print; switch (result) { case FP_ENROLL_COMPLETE: tmp = "Enrollment completed!"; break; case FP_ENROLL_PASS: tmp = g_strdup_printf("Step %d of %d", ++enroll_stage, nr_enroll_stages); free_tmp = TRUE; break; case FP_ENROLL_FAIL: tmp = "Enrollment failed!"; break; case FP_ENROLL_RETRY: tmp = "Bad scan. Please try again."; break; case FP_ENROLL_RETRY_TOO_SHORT: tmp = "Bad scan: swipe was too short. Please try again."; break; case FP_ENROLL_RETRY_CENTER_FINGER: tmp = "Bad scan: finger was not centered on scanner. Please " "try again."; break; case FP_ENROLL_RETRY_REMOVE_FINGER: tmp = "Bad scan: please remove finger before retrying."; break; default: tmp = "Unknown state!"; } gtk_label_set_markup(GTK_LABEL(edlg_progress_lbl), tmp); if (free_tmp) g_free(tmp); if (result == FP_ENROLL_COMPLETE || result == FP_ENROLL_FAIL) { enroll_complete = TRUE; edlg_cancel_enroll(result); } /* FIXME show binarized images? */ } /* called when enrollment dialog is closed. determine if it was cancelled * or if there is a print to be saved. */ static void enroll_response(GtkWidget *widget, gint arg, gpointer data) { int r; destroy_enroll_dialog(edlg_dialog); if (arg == GTK_RESPONSE_CANCEL) { if (!enroll_complete) edlg_cancel_enroll(0); return; } g_assert(edlg_enroll_data); r = fp_print_data_save(edlg_enroll_data, edlg_finger); fp_print_data_free(edlg_enroll_data); if (r < 0) { GtkWidget *dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(mwin_window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Could not save enroll data, error %d", r, NULL); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } mwin_refresh_prints(); return; } /* open enrollment dialog and start enrollment */ static void ewin_cb_enroll_clicked(GtkWidget *widget, gpointer data) { int r; GtkWidget *dialog; edlg_finger = GPOINTER_TO_INT(data); edlg_enroll_data = NULL; enroll_stage = 1; enroll_complete = FALSE; dialog = create_enroll_dialog(); r = fp_async_enroll_start(fpdev, enroll_stage_cb, dialog); if (r < 0) { destroy_enroll_dialog(dialog); dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(mwin_window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Failed to start enrollment, error %d", r, NULL); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } g_signal_connect(dialog, "response", G_CALLBACK(enroll_response), NULL); run_enroll_dialog(dialog); } static void ewin_cb_delete_clicked(GtkWidget *widget, gpointer data) { int finger = GPOINTER_TO_INT(data); int r; r = fp_print_data_delete(fpdev, finger); if (r < 0) { GtkWidget *dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(mwin_window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Could not delete enroll data, error %d", r, NULL); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } mwin_refresh_prints(); } static void ewin_clear(void) { int i; for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) { gtk_widget_set_sensitive(ewin_enroll_btn[i], FALSE); gtk_widget_set_sensitive(ewin_delete_btn[i], FALSE); gtk_label_set_text(GTK_LABEL(ewin_status_lbl[i]), "Not enrolled"); } } static void ewin_refresh(void) { struct fp_dscv_print *print; int i; for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) { gtk_label_set_text(GTK_LABEL(ewin_status_lbl[i]), "Not enrolled"); gtk_widget_set_sensitive(ewin_delete_btn[i], FALSE); } i = 0; while ((print = fp_dscv_prints[i++])) { int fnum; if (!fp_dev_supports_dscv_print(fpdev, print)) continue; fnum = fp_dscv_print_get_finger(print); gtk_label_set_text(GTK_LABEL(ewin_status_lbl[fnum]), "Enrolled"); gtk_widget_set_sensitive(ewin_delete_btn[fnum], TRUE); } } static void ewin_activate_dev(void) { struct fp_dscv_print *print; int i = 0; g_assert(fpdev); g_assert(fp_dscv_prints); while ((print = fp_dscv_prints[i++])) { int fnum; if (!fp_dev_supports_dscv_print(fpdev, print)) continue; fnum = fp_dscv_print_get_finger(print); gtk_label_set_text(GTK_LABEL(ewin_status_lbl[fnum]), "Enrolled"); gtk_widget_set_sensitive(ewin_delete_btn[fnum], TRUE); } for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) gtk_widget_set_sensitive(ewin_enroll_btn[i], TRUE); } static GtkWidget *ewin_create(void) { GtkWidget *vbox; GtkWidget *table; int i; vbox = gtk_vbox_new(FALSE, 0); table = gtk_table_new(10, 4, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 5); for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) { GtkWidget *button, *label; gchar *tmp; label = gtk_label_new(NULL); tmp = g_strdup_printf("%s", fingerstr(i)); gtk_label_set_markup(GTK_LABEL(label), tmp); g_free(tmp); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, i - 1, i); ewin_status_lbl[i] = gtk_label_new(NULL); gtk_table_attach_defaults(GTK_TABLE(table), ewin_status_lbl[i], 1, 2, i - 1, i); button = gtk_button_new_with_label("Enroll"); gtk_table_attach_defaults(GTK_TABLE(table), button, 2, 3, i - 1, i); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(ewin_cb_enroll_clicked), GINT_TO_POINTER(i)); ewin_enroll_btn[i] = button; button = gtk_button_new_from_stock(GTK_STOCK_DELETE); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(ewin_cb_delete_clicked), GINT_TO_POINTER(i)); gtk_table_attach_defaults(GTK_TABLE(table), button, 3, 4, i - 1, i); ewin_delete_btn[i] = button; } gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); return vbox; } struct fpd_tab enroll_tab = { .name = "Enroll", .create = ewin_create, .clear = ewin_clear, .activate_dev = ewin_activate_dev, .refresh = ewin_refresh, }; ./src/identify.c0000644000175000017500000002621411104426331013273 0ustar dererkdererk/* * fprint_demo: Demonstration of libfprint's capabilities * Copyright (C) 2007-2008 Daniel Drake * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include "fprint_demo.h" static GtkWidget *iwin_verify_img; static GtkWidget *iwin_ify_status; static GtkWidget *iwin_ify_button; static GtkWidget *iwin_non_img_label; static GtkWidget *iwin_fing_checkbox[RIGHT_LITTLE + 1]; static struct fp_img *img_normal = NULL; static struct fp_print_data **gallery = NULL; static int *fingnum = NULL; static void iwin_ify_status_not_capable(void) { gtk_label_set_markup(GTK_LABEL(iwin_ify_status), "Status: Device does not support identification."); gtk_widget_set_sensitive(iwin_ify_button, FALSE); } static void iwin_clear(void) { int i; fp_img_free(img_normal); img_normal = NULL; gtk_image_clear(GTK_IMAGE(iwin_verify_img)); for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) { gtk_widget_set_sensitive(iwin_fing_checkbox[i], FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(iwin_fing_checkbox[i]), FALSE); } gtk_label_set_text(GTK_LABEL(iwin_ify_status), NULL); gtk_widget_set_sensitive(iwin_ify_button, FALSE); } static void iwin_refresh(void) { struct fp_dscv_print *print; int i; /* mark all fingers insensitive */ for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) gtk_widget_set_sensitive(iwin_fing_checkbox[i], FALSE); /* resensitize detected fingers */ i = 0; while ((print = fp_dscv_prints[i++])) { int fnum; if (!fp_dev_supports_dscv_print(fpdev, print)) continue; fnum = fp_dscv_print_get_finger(print); gtk_widget_set_sensitive(iwin_fing_checkbox[fnum], TRUE); } /* untick any fingers that are not sensitive */ for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) { if (!GTK_WIDGET_SENSITIVE(iwin_fing_checkbox[i])) gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(iwin_fing_checkbox[i]), FALSE); } } static void iwin_activate_dev(void) { struct fp_dscv_print *print; int i = 0; g_assert(fpdev); g_assert(fp_dscv_prints); if (!fp_dev_supports_identification(fpdev)) { iwin_ify_status_not_capable(); return; } while ((print = fp_dscv_prints[i++])) { int fnum; if (!fp_dev_supports_dscv_print(fpdev, print)) continue; fnum = fp_dscv_print_get_finger(print); gtk_widget_set_sensitive(iwin_fing_checkbox[fnum], TRUE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( iwin_fing_checkbox[fnum]), TRUE); } if (fp_dev_supports_imaging(fpdev)) { int width = fp_dev_get_img_width(fpdev); int height = fp_dev_get_img_height(fpdev); gtk_widget_set_size_request(iwin_verify_img, (width == 0) ? 192 : width, (height == 0) ? 192 : height); gtk_widget_hide(iwin_non_img_label); gtk_widget_show(iwin_verify_img); } else { gtk_widget_show(iwin_non_img_label); gtk_widget_hide(iwin_verify_img); } } static void iwin_ify_result_other(int code) { const char *msgs[] = { [FP_VERIFY_NO_MATCH] = "Could not identify finger.", [FP_VERIFY_MATCH] = "Finger matches!", [FP_VERIFY_RETRY] = "Bad scan.", [FP_VERIFY_RETRY_TOO_SHORT] = "Swipe was too short.", [FP_VERIFY_RETRY_CENTER_FINGER] = "Finger was not centered on sensor.", [FP_VERIFY_RETRY_REMOVE_FINGER] = "Bad scan, remove finger.", }; gchar *msg; if (code < 0) msg = g_strdup_printf("Status: Scan failed, error %d", code); else msg = g_strdup_printf("Status: %s", msgs[code]); gtk_label_set_markup(GTK_LABEL(iwin_ify_status), msg); g_free(msg); } static void iwin_ify_result_match(int fnum) { gchar *tmp = g_ascii_strdown(fingerstr(fnum), -1); gchar *msg = g_strdup_printf("Status: Matched %s", tmp); g_free(tmp); gtk_label_set_markup(GTK_LABEL(iwin_ify_status), msg); g_free(msg); } static void iwin_img_draw(void) { unsigned char *rgbdata; GdkPixbuf *pixbuf; int width; int height; if (!img_normal) return; rgbdata = img_to_rgbdata(img_normal); width = fp_img_get_width(img_normal); height = fp_img_get_height(img_normal); gtk_widget_set_size_request(iwin_verify_img, width, height); pixbuf = gdk_pixbuf_new_from_data(rgbdata, GDK_COLORSPACE_RGB, FALSE, 8, width, height, width * 3, pixbuf_destroy, NULL); gtk_image_set_from_pixbuf(GTK_IMAGE(iwin_verify_img), pixbuf); g_object_unref(pixbuf); } static void iwin_cb_fing_checkbox_toggled(GtkToggleButton *button, gpointer data) { int i; if (gtk_toggle_button_get_active(button)) { gtk_widget_set_sensitive(iwin_ify_button, TRUE); return; } for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) { if (gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(iwin_fing_checkbox[i]))) { gtk_widget_set_sensitive(iwin_ify_button, TRUE); return; } } gtk_widget_set_sensitive(iwin_ify_button, FALSE); } static struct fp_dscv_print *dscv_print_for_finger(int fnum) { int i = 0; struct fp_dscv_print *dprint; while ((dprint = fp_dscv_prints[i++])) { if (!fp_dev_supports_dscv_print(fpdev, dprint)) continue; if (fp_dscv_print_get_finger(dprint) == fnum) return dprint; } return NULL; } static void __identify_cleanup(GtkWidget *dialog) { struct fp_print_data *print; int i = 0; gtk_widget_destroy(dialog); while ((print = gallery[i++])) fp_print_data_free(print); g_free(gallery); g_free(fingnum); fingnum = NULL; gallery = NULL; } static void identify_stopped_cb(struct fp_dev *dev, void *user_data) { __identify_cleanup(GTK_WIDGET(user_data)); } static void identify_cb(struct fp_dev *dev, int result, size_t match_offset, struct fp_img *img, void *user_data) { GtkWidget *dialog; int r; destroy_scan_finger_dialog(GTK_WIDGET(user_data)); if (result == FP_VERIFY_MATCH) iwin_ify_result_match(fingnum[match_offset]); else iwin_ify_result_other(result); fp_img_free(img_normal); img_normal = NULL; if (img) { img_normal = img; iwin_img_draw(); } dialog = run_please_wait_dialog("Ending identification..."); r = fp_async_identify_stop(dev, identify_stopped_cb, dialog); if (r < 0) __identify_cleanup(dialog); } static void scan_finger_response(GtkWidget *dialog, gint arg, gpointer user_data) { int r; destroy_scan_finger_dialog(dialog); dialog = run_please_wait_dialog("Ending identification..."); r = fp_async_identify_stop(fpdev, identify_stopped_cb, dialog); if (r < 0) __identify_cleanup(dialog); } static void iwin_cb_identify(GtkWidget *widget, gpointer user_data) { struct fp_print_data *print; GtkWidget *dialog; int i; int r; size_t offset = 0; int selected_fingers = 0; /* count number of selected fingers */ for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) if (gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(iwin_fing_checkbox[i]))) selected_fingers++; g_assert(selected_fingers); /* allocate list for print gallery */ gallery = g_malloc0(sizeof(*gallery) * (selected_fingers + 1)); gallery[selected_fingers] = NULL; /* NULL-terminate */ fingnum = g_malloc(sizeof(*fingnum) * selected_fingers); /* populate print gallery from selected fingers */ for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) { struct fp_dscv_print *dprint; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(iwin_fing_checkbox[i]))) continue; dprint = dscv_print_for_finger(i); g_assert(dprint); r = fp_print_data_from_dscv_print(dprint, &print); if (r < 0) { dprint = NULL; goto err; } gallery[offset] = print; fingnum[offset] = fp_dscv_print_get_finger(dprint); offset++; } /* do identification */ dialog = create_scan_finger_dialog(); r = fp_async_identify_start(fpdev, gallery, identify_cb, dialog); if (r < 0) { destroy_scan_finger_dialog(dialog); dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(mwin_window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Could not start identification, error %d", r, NULL); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); return; } g_signal_connect(dialog, "response", G_CALLBACK(scan_finger_response), NULL); run_scan_finger_dialog(dialog); return; err: /* FIXME this leaks the gallery and any already-scanned prints */ dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(mwin_window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Could not load print for %s, error %d", fingerstr(i), r, NULL); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } static GtkWidget *iwin_create(void) { GtkWidget *ui_vbox; GtkWidget *label, *vfy_vbox, *ify_frame, *scan_frame, *img_vbox; GtkWidget *iwin_main_hbox; int i; iwin_main_hbox = gtk_hbox_new(FALSE, 1); /* Image frame */ scan_frame = gtk_frame_new("Scanned Image"); gtk_box_pack_start(GTK_BOX(iwin_main_hbox), scan_frame, TRUE, TRUE, 0); /* Image vbox */ img_vbox = gtk_vbox_new(FALSE, 1); gtk_container_add(GTK_CONTAINER(scan_frame), img_vbox); /* Image */ iwin_verify_img = gtk_image_new(); gtk_box_pack_start(GTK_BOX(img_vbox), iwin_verify_img, TRUE, FALSE, 0); /* Non-imaging device */ iwin_non_img_label = gtk_label_new("This device does not have imaging " "capabilities, no images will be displayed."); gtk_box_pack_start_defaults(GTK_BOX(img_vbox), iwin_non_img_label); /* vbox for verification status and image control frames */ ui_vbox = gtk_vbox_new(FALSE, 1); gtk_box_pack_end(GTK_BOX(iwin_main_hbox), ui_vbox, FALSE, FALSE, 0); /* Identification status */ ify_frame = gtk_frame_new("Identification"); gtk_box_pack_start_defaults(GTK_BOX(ui_vbox), ify_frame); vfy_vbox = gtk_vbox_new(FALSE, 1); gtk_container_add(GTK_CONTAINER(ify_frame), vfy_vbox); /* Discovered prints list */ label = gtk_label_new("Select fingers to identify against:"); gtk_box_pack_start(GTK_BOX(vfy_vbox), label, FALSE, FALSE, 0); for (i = LEFT_THUMB; i <= RIGHT_LITTLE; i++) { GtkWidget *checkbox = gtk_check_button_new_with_label(fingerstr(i)); gtk_box_pack_start(GTK_BOX(vfy_vbox), checkbox, FALSE, FALSE, 0); g_signal_connect(GTK_OBJECT(checkbox), "toggled", G_CALLBACK(iwin_cb_fing_checkbox_toggled), NULL); iwin_fing_checkbox[i] = checkbox; } /* Identify button */ iwin_ify_button = gtk_button_new_with_label("Identify"); g_signal_connect(G_OBJECT(iwin_ify_button), "clicked", G_CALLBACK(iwin_cb_identify), NULL); gtk_box_pack_start(GTK_BOX(vfy_vbox), iwin_ify_button, FALSE, FALSE, 0); /* Identify status */ iwin_ify_status = gtk_label_new(NULL); gtk_box_pack_start(GTK_BOX(vfy_vbox), iwin_ify_status, FALSE, FALSE, 0); return iwin_main_hbox; } struct fpd_tab identify_tab = { .name = "Identify", .create = iwin_create, .activate_dev = iwin_activate_dev, .clear = iwin_clear, .refresh = iwin_refresh, }; ./src/fprint_demo.h0000644000175000017500000000345611104426331013776 0ustar dererkdererk/* * fprint_demo: Demonstration of libfprint's capabilities * Copyright (C) 2007 Daniel Drake * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef __FPRINT_DEMO_H__ #define __FPRINT_DEMO_H__ #include #include #include /* main.c */ extern struct fp_dev *fpdev; extern struct fp_dscv_print **fp_dscv_prints; extern GtkWidget *mwin_window; const char *fingerstr(enum fp_finger finger); void pixbuf_destroy(guchar *pixels, gpointer data); unsigned char *img_to_rgbdata(struct fp_img *img); GdkPixbuf *img_to_pixbuf(struct fp_img *img); void mwin_refresh_prints(void); /* tabs */ struct fpd_tab { const char *name; GtkWidget *(*create)(void); void (*activate_dev)(void); void (*clear)(void); void (*refresh)(void); }; extern struct fpd_tab enroll_tab; extern struct fpd_tab verify_tab; extern struct fpd_tab identify_tab; extern struct fpd_tab img_tab; /* helper dialogs */ GtkWidget *run_please_wait_dialog(char *msg); GtkWidget *create_scan_finger_dialog(void); void run_scan_finger_dialog(GtkWidget *dialog); void destroy_scan_finger_dialog(GtkWidget *dialog); #endif ./NEWS0000644000175000017500000000070711104426331011223 0ustar dererkdererkThis file lists notable changes in each release. For the full history of all changes, see ChangeLog. 2007-11-22: v0.4 release * Add identification functionality 2007-11-19: v0.3 release * Add functionality to delete enroll data * Add functionality to plot minutiae 2007-11-18: v0.2 release * Add functionality to save images * Tabbed interface * Add enrollment GUI * Improve window sizing behaviour 2007-11-17: v0.1 release * Initial release ./icons/0000755000175000017500000000000011104426331011633 5ustar dererkdererk./icons/16x16/0000755000175000017500000000000011104426331012420 5ustar dererkdererk./icons/16x16/fprint_demo.png0000644000175000017500000000105011104426331015430 0ustar dererkdererkPNG  IHDRsO/sRGBbKGD pHYs B(xtIME : IDAT(ϥKTQ{1wFE0TͤP)f`TEA7E;'jѮE(D( !QqETf6EE038ÿ7v'q{;rKқ1P0rk-&m:w:%k^|S p>pRe  _}&m.T&lk2c@!|ֆhmξ*J)Oh@5hȏ7@9Lx c @5`d;뫝^5`NbiEK è"Ҋ-{ p _ۗp{zs6:` Oۍyu3LԔZ'r5oOIrJ8p7 `:Z|1p ܨop^ |"ї4*.R%gIENDB`./icons/22x22/0000755000175000017500000000000011104426331012412 5ustar dererkdererk./icons/22x22/fprint_demo.png0000644000175000017500000000142511104426331015430 0ustar dererkdererkPNG  IHDR+vsRGBbKGD pHYs B(xtIME1M_(IDAT8˵OHUA{G>L3 -"EVPE@(jAm*H C R?Y.λsm(-ezV3s|w`X&wh@ x{VE>qyS$p #v膖 11c^ItvW /'An'RӐ.;c1j#yAIelٙsS ffQ!x*d,ulN7h{_cًYI-iMZCS˱at˶ݣo@/fFiń3QBJ%U#А̓ah `zAm1KigsLWO A[2|ؙjV!`6 U2 Z؎r]ܤ`}"9>^ ʆMcb ъr34ͺHrT>]EC*V8Pd[ Gs;к%$1'}4|<vW]oU{Y\%~5G 6[û\\\q?p0o't3@GGkm@*< k] xe 6BKڧڈ+Ģ2s_bq f(k9TɭZ[t~!5/;k筬>:AcW޲< $ N\%pQT.(.?Di,Co:&F^ąӏug[k~(Z;zpgݙUχG Yy-7%9S=,[2sT/9j%nn> X-(OqQd-m35r-#$RZ<3'viȨzϮoݙn[Fֹw?Zݾ eX,!n&ڧ߯DjH 1PKT!bennt=hsTn`l&u t  ڕ{J]oٱ49<`Oks-]~fkHܶ.x% Fm$~'sLTQMawR y}Hvx8St?Vm:i+z7zQiVm3s$bۙ>vH.Wb(,Q#1zk&R]-Կ2wQ}IȮt^71.~Dnc}nhT==>KXl4e#;_m\)Y@*%Hę>@YSzG5d ^V J4-1Hm^6Oښ1%hK %: zJt,Ղ9/nu'_ D=p*>]1pfVEZNC-yb:P#qK@%GiE`ZL(`e|Pi] s%Urc RҴRg@i6NUuUFbRZĈeNv;p潌STvp0 M32ҿ Ts.;F%´߉P-+I]!O~Ɓ. |.5 Hk5bٺ<|)N7 8\-tm/fIwWIyX̄܅ߟHGgKv}|8ԉmHrRrKLe LI1 2:T`.ޯw܃G$ 0(P2 47HP-f"4)ap8—i3B:H`Y N ο1:o@w '* Uu#&ShJrJ'ޞ"D2r,'j۵)6|8~=^Q׌n2 ! (7PjlhRTӈ>5^AhŒ&K/vg?ѨB8` U Cvp`f 8(Ͽ.;f *p @WE0@ԹE1[E%R1iV,T5;Ŏe#`xDځS%v$qTHb/%/]\.&?.~iGmQ 7rH 3aBـ^]ƙ`g %v)Nx IENDB`./icons/scalable/0000755000175000017500000000000011104426331013401 5ustar dererkdererk./icons/scalable/fprint_demo.svg0000644000175000017500000024515311104426331016442 0ustar dererkdererk image/svg+xmlFprint LogoTorkild Retvedtfingerprint magnyfing glass fprint ./icons/Makefile.am0000644000175000017500000000106111104426331013665 0ustar dererkdererkthemedir = $(datadir)/icons/hicolor scalabledir = $(themedir)/scalable/apps scalable_DATA = scalable/fprint_demo.svg icon16x16dir = $(themedir)/16x16/apps icon16x16_DATA = 16x16/fprint_demo.png icon22x22dir = $(themedir)/22x22/apps icon22x22_DATA = 22x22/fprint_demo.png icon48x48dir = $(themedir)/48x48/apps icon48x48_DATA = 48x48/fprint_demo.png icon128x128dir = $(themedir)/128x128/apps icon128x128_DATA = 128x128/fprint_demo.png EXTRA_DIST = \ $(scalable_DATA) \ $(icon16x16_DATA) \ $(icon22x22_DATA) \ $(icon48x48_DATA) \ $(icon128x128_DATA) ./icons/128x128/0000755000175000017500000000000011104426331012570 5ustar dererkdererk./icons/128x128/fprint_demo.png0000644000175000017500000004411411104426331015610 0ustar dererkdererkPNG  IHDR?+JsRGBbKGD pHYs B(xtIME 2w1 IDATxux\ I1[X̘:ش6PLbv [LkM~[H)MIrqbf%[43>1m]u#y~=p]iWڕv]iWڕv]iWڕv]i+t\d gT=-X  l 0@X!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?QR&öCOɃFүJc܇\DSN1Z=OCoJU 6uLn2-Y)'Pŏ-YiP!#-Y)#Xؐ%𖬔,%oJ}qH}xKVZ,alH:%+M 06$ޒ06d"%+7!=.[,%~ /v$-'+ -dt>j ȍI,UlˆJdb(k-%j[ BŬt-χ) $@I?_U*d9IENDB`./README0000644000175000017500000000047011104426331011401 0ustar dererkdererkfprint_demo =========== http://www.reactivated.net/fprint/wiki/Fprint_demo Software to demonstrate libfprint's capabilities. Currently in early stages. Might eat your cat. Written in C. Requires libfprint and GTK+. Licensed under the GPL version 2 (see COPYING). TODO: Add bare image capture functionality ./configure.ac0000644000175000017500000000135211104426331013007 0ustar dererkdererkAC_INIT([fprint_demo], [0.4]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([src/main.c]) AC_PREREQ([2.50]) AC_PROG_CC AM_PROG_CC_C_O PKG_CHECK_MODULES(FPRINT, "libfprint") AC_SUBST(FPRINT_LIBS) AC_SUBST(FPRINT_CFLAGS) PKG_CHECK_MODULES(GTK, "gtk+-2.0") AC_SUBST(GTK_LIBS) AC_SUBST(GTK_CFLAGS) # Restore gnu89 inline semantics on gcc 4.3 and newer saved_cflags="$CFLAGS" CFLAGS="$CFLAGS -fgnu89-inline" AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="") CFLAGS="$saved_cflags" AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration -Wno-pointer-sign -Wshadow" AC_SUBST(AM_CFLAGS) AC_CONFIG_FILES([Makefile] [src/Makefile] [icons/Makefile]) AC_OUTPUT ./autogen.sh0000755000175000017500000000016011104426331012516 0ustar dererkdererk#!/bin/sh aclocal || exit 1 autoconf || exit 1 automake -a -c || exit 1 ./configure --enable-maintainer-mode $* ./fprint_demo.desktop0000644000175000017500000000067411104426331014430 0ustar dererkdererk[Desktop Entry] Encoding=UTF-8 Name=fprint project demo GenericName=Fingerprint demo program GenericName[fr]=Logiciel de démonstration de reconnaissances des empreintes digitales Comment=Fingerprint scanning demonstration Comment[fr]=Logiciel de démonstration pour le programme de reconnaissance d'empreinte digitale fprint Exec=fprint_demo Icon=fprint_demo Terminal=false Type=Application Categories=Utility;ComputerScience;ImageProcessing; ./Makefile.am0000644000175000017500000000060211104426331012552 0ustar dererkdererkAUTOMAKE_OPTIONS = dist-bzip2 SUBDIRS = src icons DISTCLEANFILES = ChangeLog desktopdir = $(datadir)/applications desktop_DATA = fprint_demo.desktop EXTRA_DIST = $(desktop_DATA) .PHONY: ChangeLog dist-up ChangeLog: git --git-dir $(top_srcdir)/.git log > ChangeLog || touch ChangeLog dist-hook: ChangeLog dist-up: dist ncftpput upload.sourceforge.net incoming $(distdir).tar.bz2 ./AUTHORS0000644000175000017500000000003611104426331011567 0ustar dererkdererkDaniel Drake ./INSTALL0000644000175000017500000002231011104426331011547 0ustar dererkdererkInstallation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. ./COPYING0000644000175000017500000004312211104426331011555 0ustar dererkdererk GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.