2 * Example libfprint image capture program
3 * Copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <libfprint/fprint.h>
25 struct fp_dscv_dev
*discover_device(struct fp_dscv_dev
**discovered_devs
)
27 struct fp_dscv_dev
*ddev
= NULL
;
30 for (i
= 0; ddev
= discovered_devs
[i
]; i
++) {
31 struct fp_driver
*drv
= fp_dscv_dev_get_driver(ddev
);
32 printf("Found device claimed by %s driver\n",
33 fp_driver_get_full_name(drv
));
43 struct fp_dscv_dev
*ddev
;
44 struct fp_dscv_dev
**discovered_devs
;
46 struct fp_img
*img
= NULL
;
50 fprintf(stderr
, "Failed to initialize libfprint\n");
54 discovered_devs
= fp_discover_devs();
55 if (!discovered_devs
) {
56 fprintf(stderr
, "Could not discover devices\n");
60 ddev
= discover_device(discovered_devs
);
62 fprintf(stderr
, "No devices detected.\n");
66 dev
= fp_dev_open(ddev
);
67 fp_dscv_devs_free(discovered_devs
);
69 fprintf(stderr
, "Could not open device.\n");
73 if (!fp_dev_supports_imaging(dev
)) {
74 fprintf(stderr
, "this device does not have imaging capabilities.\n");
78 printf("Opened device. It's now time to scan your finger.\n\n");
80 r
= fp_dev_img_capture(dev
, 0, &img
);
82 fprintf(stderr
, "image capture failed, code %d\n", r
);
86 r
= fp_img_save_to_file(img
, "finger.pgm");
88 fprintf(stderr
, "img save failed, code %d\n", r
);
92 fp_img_standardize(img
);
93 r
= fp_img_save_to_file(img
, "finger_standardized.pgm");
96 fprintf(stderr
, "standardized img save failed, code %d\n", r
);