![]() |
The needed gxsdldr.c loader file is included directly:
The __lib__.h
file contains some library functions used only in the sample programs, such as the lib_function_start
and lib_function_end
functions that implement the simple command line interface and measures the elapsed time between the two function calls.
#include "../__lib__.h"
The main function:
int main() {
Opening the Fingerprint Scanner system:
/* Opening the FPS system */ gxHANDLE hfps; /* handle for the FPS system */ lib_function_start("Opening system files"); if (gx_openmodulea(&hfps,"prapi","default")) lib_function_end(); else { lib_displ_err(); return 0; }
Connecting to the first device. If no device is connected then the fps_usedevicen() function returns false and the program ends:
/* Connecting to the first device */ lib_function_start("Connecting to the first device"); if (fps_usedevicen(hfps,0,FPS_UMODE_FULL_CONTROL)) { lib_function_end(); } else { lib_displ_err(); gx_closehandle(&hfps); return 0; }
The main loop begins:
while(!lib_kbhit()) { int reqid, stat, stat0; gxVARIANT v = NULL; gxVARIANT v1 = NULL; gxVARIANT v2 = NULL; lib_process_start("Processing fingers");
Resetting the internal fingerprint buffer:
/* Search Finger */ /* Clears internal stored finger buffers */ fps_resetfingerlist(hfps);
Searching for the fingerprints:
/* Starts an asynchronous capture process // params: time in usec, quality in per-thousand, mode of live scan, fingerlist // // The finger list has the format 0hhh 0000 iiii mmmm rrrr llll tttt ssss // h - scan object: 001 left hand, 010 right hand, 011 same fingers of both hands // i - index finger | // m - middle finger | // r - ring finger |--> value of FPS_PRESENCE // l - little finger | // t - left thumb | // s - right thumb | */ fps_capture_start(hfps, 10000, 700, FPS_SCAN_LIVE, 0x10333300, &reqid); for (stat = stat0 = 0; stat < 100; stat0 = stat) { /* Test if better images are captured or capture has accomplished */ fps_capture_getstatus(hfps,reqid,&stat); if (stat0 != stat) lib_write_line("stat: %i", stat); lib_wait(100); } /* Closing the capture sequence */ fps_capture_wait(hfps, reqid);
Saving the fingerprint images:
/* Save individual finger images */ fps_saveimagea(hfps, 0, FPS_POS_LEFT_INDEX, FPS_IT_FINGER, "1index.bmp", GX_BMP); fps_saveimagea(hfps, 0, FPS_POS_LEFT_MIDDLE, FPS_IT_FINGER, "2middle.bmp", GX_BMP); fps_saveimagea(hfps, 0, FPS_POS_LEFT_RING, FPS_IT_FINGER, "3ring.bmp", GX_BMP); fps_saveimagea(hfps, 0, FPS_POS_LEFT_LITTLE, FPS_IT_FINGER, "4little.bmp", GX_BMP);
Exporting the result into a nist file:
/* This section modifies the values of nist record */ gx_createvariant(&v, 0, GX_VARIANT_LIST, 0, 0, 0); /* General list */ gx_createvariant(&v1, 1, GX_VARIANT_LIST, 0, 0, 0); /* List for storing the type-1 record data */ gx_addvariantitem(v, GX_VARIANT_LAST, 0, 0, v1); gx_createvariant(&v2, 4, GX_VARIANT_ASCII, strlen("ATP"), 1, "ATP"); gx_addvariantitem(v1, GX_VARIANT_LAST, 0, 0, v2); gx_createvariant(&v1, 2, GX_VARIANT_LIST, 0, 0, 0); /* List for storing the type-2 record data */ gx_addvariantitem(v, GX_VARIANT_LAST, 0, 0, v1); gx_createvariant(&v2, 45, GX_VARIANT_ASCII, strlen("Test message")+1, 1, "Test message"); gx_addvariantitem(v1, GX_VARIANT_LAST, 0, 0, v2); gx_createvariant(&v2, 39, GX_VARIANT_ASCII, strlen("Other text")+1, 1, "Other text"); gx_addvariantitem(v1, GX_VARIANT_LAST, 0, 0, v2); /* Saves all the captured fingers */ fps_fingertonista(hfps, "mynist.nist", v);
The main loop ends:
lib_process_end(); lib_wait_for_sec(3); }
Closing the device:
/* Closing device */ lib_function_start("Closing device"); if (fps_closedevice(hfps)) { lib_function_end(); } else { lib_displ_err(); }
Closing the Fingerprint Scanner system:
/* Closing the FPS system */ lib_function_start("Closing FPS system"); if (gx_closehandle(&hfps)) { lib_function_end(); } else { lib_displ_err(); }
The sample program ends printing some statistic information:
return lib_print_stat();
}
The complete source code:
#include "fpsapi.h" #include "gxsdldr.c" #include "../__lib__.h" int main() { /* Opening the FPS system */ gxHANDLE hfps; /* handle for the FPS system */ lib_function_start("Opening system files"); if (gx_openmodulea(&hfps,"prapi","default")) lib_function_end(); else { lib_displ_err(); return 0; } /* Connecting to the first device */ lib_function_start("Connecting to the first device"); if (fps_usedevicen(hfps,0,FPS_UMODE_FULL_CONTROL)) { lib_function_end(); } else { lib_displ_err(); gx_closehandle(&hfps); return 0; } while(!lib_kbhit()) { int reqid, stat, stat0; gxVARIANT v = NULL; gxVARIANT v1 = NULL; gxVARIANT v2 = NULL; lib_process_start("Processing fingers"); /* Search Finger */ /* Clears internal stored finger buffers */ fps_resetfingerlist(hfps); /* Starts an asynchronous capture process // params: time in usec, quality in per-thousand, mode of live scan, fingerlist // // The finger list has the format 0hhh 0000 iiii mmmm rrrr llll tttt ssss // h - scan object: 001 left hand, 010 right hand, 011 same fingers of both hands // i - index finger | // m - middle finger | // r - ring finger |--> value of FPS_PRESENCE // l - little finger | // t - left thumb | // s - right thumb | */ fps_capture_start(hfps, 10000, 700, FPS_SCAN_LIVE, 0x10333300, &reqid); for (stat = stat0 = 0; stat < 100; stat0 = stat) { /* Test if better images are captured or capture has accomplished */ fps_capture_getstatus(hfps,reqid,&stat); if (stat0 != stat) lib_write_line("stat: %i", stat); lib_wait(100); } /* Closing the capture sequence */ fps_capture_wait(hfps, reqid); /* Save individual finger images */ fps_saveimagea(hfps, 0, FPS_POS_LEFT_INDEX, FPS_IT_FINGER, "1index.bmp", GX_BMP); fps_saveimagea(hfps, 0, FPS_POS_LEFT_MIDDLE, FPS_IT_FINGER, "2middle.bmp", GX_BMP); fps_saveimagea(hfps, 0, FPS_POS_LEFT_RING, FPS_IT_FINGER, "3ring.bmp", GX_BMP); fps_saveimagea(hfps, 0, FPS_POS_LEFT_LITTLE, FPS_IT_FINGER, "4little.bmp", GX_BMP); /* This section modifies the values of nist record */ gx_createvariant(&v, 0, GX_VARIANT_LIST, 0, 0, 0); /* General list */ gx_createvariant(&v1, 1, GX_VARIANT_LIST, 0, 0, 0); /* List for storing the type-1 record data */ gx_addvariantitem(v, GX_VARIANT_LAST, 0, 0, v1); gx_createvariant(&v2, 4, GX_VARIANT_ASCII, strlen("ATP"), 1, "ATP"); gx_addvariantitem(v1, GX_VARIANT_LAST, 0, 0, v2); gx_createvariant(&v1, 2, GX_VARIANT_LIST, 0, 0, 0); /* List for storing the type-2 record data */ gx_addvariantitem(v, GX_VARIANT_LAST, 0, 0, v1); gx_createvariant(&v2, 45, GX_VARIANT_ASCII, strlen("Test message")+1, 1, "Test message"); gx_addvariantitem(v1, GX_VARIANT_LAST, 0, 0, v2); gx_createvariant(&v2, 39, GX_VARIANT_ASCII, strlen("Other text")+1, 1, "Other text"); gx_addvariantitem(v1, GX_VARIANT_LAST, 0, 0, v2); /* Saves all the captured fingers */ fps_fingertonista(hfps, "mynist.nist", v); lib_process_end(); lib_wait_for_sec(3); } /* Closing device */ lib_function_start("Closing device"); if (fps_closedevice(hfps)) { lib_function_end(); } else { lib_displ_err(); } /* Closing the FPS system */ lib_function_start("Closing FPS system"); if (gx_closehandle(&hfps)) { lib_function_end(); } else { lib_displ_err(); } return lib_print_stat(); }