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
= discovered_devs
[0];
28 struct fp_driver
*drv
;
32 drv
= fp_dscv_dev_get_driver(ddev
);
33 printf("Found device claimed by %s driver\n", fp_driver_get_full_name(drv
));
40 struct fp_dscv_dev
*ddev
;
41 struct fp_dscv_dev
**discovered_devs
;
43 struct fp_img
*img
= NULL
;
47 fprintf(stderr
, "Failed to initialize libfprint\n");
52 discovered_devs
= fp_discover_devs();
53 if (!discovered_devs
) {
54 fprintf(stderr
, "Could not discover devices\n");
58 ddev
= discover_device(discovered_devs
);
60 fprintf(stderr
, "No devices detected.\n");
64 dev
= fp_dev_open(ddev
);
65 fp_dscv_devs_free(discovered_devs
);
67 fprintf(stderr
, "Could not open device.\n");
71 if (!fp_dev_supports_imaging(dev
)) {
72 fprintf(stderr
, "this device does not have imaging capabilities.\n");
76 printf("Opened device. It's now time to scan your finger.\n\n");
78 r
= fp_dev_img_capture(dev
, 0, &img
);
80 fprintf(stderr
, "image capture failed, code %d\n", r
);
84 r
= fp_img_save_to_file(img
, "finger.pgm");
86 fprintf(stderr
, "img save failed, code %d\n", r
);
90 fp_img_standardize(img
);
91 r
= fp_img_save_to_file(img
, "finger_standardized.pgm");
94 fprintf(stderr
, "standardized img save failed, code %d\n", r
);