Add AES2501 driver
[libfprint.git] / libfprint / nbis / include / bozorth.h
blobdbac4094f5ba814c7228c153af6688191c70a040
1 /*******************************************************************************
3 License:
4 This software was developed at the National Institute of Standards and
5 Technology (NIST) by employees of the Federal Government in the course
6 of their official duties. Pursuant to title 17 Section 105 of the
7 United States Code, this software is not subject to copyright protection
8 and is in the public domain. NIST assumes no responsibility whatsoever for
9 its use by other parties, and makes no guarantees, expressed or implied,
10 about its quality, reliability, or any other characteristic.
12 Disclaimer:
13 This software was developed to promote biometric standards and biometric
14 technology testing for the Federal Government in accordance with the USA
15 PATRIOT Act and the Enhanced Border Security and Visa Entry Reform Act.
16 Specific hardware and software products identified in this software were used
17 in order to perform the software development. In no case does such
18 identification imply recommendation or endorsement by the National Institute
19 of Standards and Technology, nor does it imply that the products and equipment
20 identified are necessarily the best available for the purpose.
22 *******************************************************************************/
24 #ifndef _BOZORTH_H
25 #define _BOZORTH_H
27 /* The max number of points in any Probe or Gallery XYT is set to 200; */
28 /* a pointwise comparison table therefore has a maximum number of: */
29 /* (200^2)/2 = 20000 comparisons. */
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <sys/types.h>
35 #include <unistd.h> /* Needed for type pid_t */
36 #include <errno.h>
38 /* If not defined in sys/param.h */
39 #ifndef MAX
40 #define MAX(a,b) (((a)>(b))?(a):(b))
41 #endif
43 /**************************************************************************/
44 /* Math-Related Macros, Definitions & Prototypes */
45 /**************************************************************************/
46 #include <math.h>
47 /* This macro adjusts angles to the range (-180,180] */
48 #define IANGLE180(deg) ( ( (deg) > 180 ) ? ( (deg) - 360 ) : ( (deg) <= -180 ? ( (deg) + 360 ) : (deg) ) )
50 #define SENSE(a,b) ( (a) < (b) ? (-1) : ( ( (a) == (b) ) ? 0 : 1 ) )
51 #define SENSE_NEG_POS(a,b) ( (a) < (b) ? (-1) : 1 )
53 #define SQUARED(n) ( (n) * (n) )
55 #ifdef ROUND_USING_LIBRARY
56 /* These functions should be declared in math.h:
57 extern float roundf( float );
58 extern double round( double );
60 #define ROUND(f) (roundf(f))
61 #else
62 #define ROUND(f) ( ( (f) < 0.0F ) ? ( (int) ( (f) - 0.5F ) ) : ( (int) ( (f) + 0.5F ) ) )
63 #endif
65 /* PI is used in: bozorth3.c, comp.c */
66 #ifdef M_PI
67 #define PI M_PI
68 #define PI_SINGLE ( (float) PI )
69 #else
70 #define PI 3.14159
71 #define PI_SINGLE 3.14159F
72 #endif
74 /* Provide prototype for atanf() */
75 extern float atanf( float );
77 /**************************************************************************/
78 /* Array Length Definitions */
79 /**************************************************************************/
80 #include <bz_array.h>
83 /**************************************************************************/
84 /**************************************************************************/
85 /* GENERAL DEFINITIONS */
86 /**************************************************************************/
88 #define FPNULL ((FILE *) NULL)
89 #define CNULL ((char *) NULL)
91 #define PROGRAM "bozorth3"
93 #define MAX_LINE_LENGTH 1024
95 #define SCOREFILE_EXTENSION ".scr"
97 #define MAX_FILELIST_LENGTH 10000
99 #define DEFAULT_BOZORTH_MINUTIAE 150
100 #define MAX_BOZORTH_MINUTIAE 200
101 #define MIN_BOZORTH_MINUTIAE 0
102 #define MIN_COMPUTABLE_BOZORTH_MINUTIAE 10
104 #define DEFAULT_MAX_MATCH_SCORE 400
105 #define ZERO_MATCH_SCORE 0
107 #define DEFAULT_SCORE_LINE_FORMAT "s"
109 #define DM 125
110 #define FD 5625
111 #define FDD 500
112 #define TK 0.05F
113 #define TXS 121
114 #define CTXS 121801
115 #define MSTR 3
116 #define MMSTR 8
117 #define WWIM 10
119 #define QQ_SIZE 4000
121 #define QQ_OVERFLOW_SCORE QQ_SIZE
123 /**************************************************************************/
124 /**************************************************************************/
125 /* MACROS DEFINITIONS */
126 /**************************************************************************/
127 #define INT_SET(dst,count,value) { \
128 int * int_set_dst = (dst); \
129 int int_set_count = (count); \
130 int int_set_value = (value); \
131 while ( int_set_count-- > 0 ) \
132 *int_set_dst++ = int_set_value; \
135 /* The code that calls it assumed dst gets bumped, so don't assign to a local variable */
136 #define INT_COPY(dst,src,count) { \
137 int * int_copy_src = (src); \
138 int int_copy_count = (count); \
139 while ( int_copy_count-- > 0 ) \
140 *dst++ = *int_copy_src++; \
144 /**************************************************************************/
145 /**************************************************************************/
146 /* STRUCTURES & TYPEDEFS */
147 /**************************************************************************/
149 /**************************************************************************/
150 /* In BZ_SORT.C - supports stdlib qsort() and customized quicksort */
151 /**************************************************************************/
153 /* Used by call to stdlib qsort() */
154 struct minutiae_struct {
155 int col[4];
158 /* Used by custom quicksort */
159 #define BZ_STACKSIZE 1000
160 struct cell {
161 int index; /* pointer to an array of pointers to index arrays */
162 int item; /* pointer to an item array */
165 /**************************************************************************/
166 /* In BZ_IO : Supports the loading and manipulation of XYT data */
167 /**************************************************************************/
168 #define MAX_FILE_MINUTIAE 1000 /* bz_load() */
170 struct xyt_struct {
171 int nrows;
172 int xcol[ MAX_BOZORTH_MINUTIAE ];
173 int ycol[ MAX_BOZORTH_MINUTIAE ];
174 int thetacol[ MAX_BOZORTH_MINUTIAE ];
177 #define XYT_NULL ( (struct xyt_struct *) NULL ) /* bz_load() */
180 /**************************************************************************/
181 /**************************************************************************/
182 /* GLOBAL VARIABLES */
183 /**************************************************************************/
185 /**************************************************************************/
186 /* In: SRC/BIN/BOZORTH3/BOZORTH3.C */
187 /**************************************************************************/
188 /* Globals supporting command line options */
189 extern int verbose_threshold;
191 /**************************************************************************/
192 /* In: BZ_GBLS.C */
193 /**************************************************************************/
194 /* Global arrays supporting "core" bozorth algorithm */
195 extern int colp[ COLP_SIZE_1 ][ COLP_SIZE_2 ];
196 extern int scols[ SCOLS_SIZE_1 ][ COLS_SIZE_2 ];
197 extern int fcols[ FCOLS_SIZE_1 ][ COLS_SIZE_2 ];
198 extern int * scolpt[ SCOLPT_SIZE ];
199 extern int * fcolpt[ FCOLPT_SIZE ];
200 extern int sc[ SC_SIZE ];
201 extern int yl[ YL_SIZE_1 ][ YL_SIZE_2 ];
202 /* Global arrays supporting "core" bozorth algorithm continued: */
203 /* Globals used significantly by sift() */
204 extern int rq[ RQ_SIZE ];
205 extern int tq[ TQ_SIZE ];
206 extern int zz[ ZZ_SIZE ];
207 extern int rx[ RX_SIZE ];
208 extern int mm[ MM_SIZE ];
209 extern int nn[ NN_SIZE ];
210 extern int qq[ QQ_SIZE ];
211 extern int rk[ RK_SIZE ];
212 extern int cp[ CP_SIZE ];
213 extern int rp[ RP_SIZE ];
214 extern int rf[RF_SIZE_1][RF_SIZE_2];
215 extern int cf[CF_SIZE_1][CF_SIZE_2];
216 extern int y[20000];
218 /**************************************************************************/
219 /**************************************************************************/
220 /* ROUTINE PROTOTYPES */
221 /**************************************************************************/
222 /* In: BZ_DRVRS.C */
223 extern int bozorth_probe_init( struct xyt_struct *);
224 extern int bozorth_gallery_init( struct xyt_struct *);
225 extern int bozorth_to_gallery(int, struct xyt_struct *, struct xyt_struct *);
226 extern int bozorth_main(struct xyt_struct *, struct xyt_struct *);
227 /* In: BOZORTH3.C */
228 extern void bz_comp(int, int [], int [], int [], int *, int [][COLS_SIZE_2],
229 int *[]);
230 extern void bz_find(int *, int *[]);
231 extern int bz_match(int, int);
232 extern int bz_match_score(int, struct xyt_struct *, struct xyt_struct *);
233 extern void bz_sift(int *, int, int *, int, int, int, int *, int *);
234 /* In: BZ_ALLOC.C */
235 extern char *malloc_or_exit(int, const char *);
236 extern char *malloc_or_return_error(int, const char *);
237 /* In: BZ_IO.C */
238 extern int parse_line_range(const char *, int *, int *);
239 extern void set_progname(int, char *, pid_t);
240 extern void set_probe_filename(char *);
241 extern void set_gallery_filename(char *);
242 extern char *get_progname(void);
243 extern char *get_probe_filename(void);
244 extern char *get_gallery_filename(void);
245 extern char *get_next_file(char *, FILE *, FILE *, int *, int *, char *,
246 int, char **, int *, int *, int, int);
247 extern char *get_score_filename(const char *, const char *);
248 extern char *get_score_line(const char *, const char *, int, int, const char *);
249 extern struct xyt_struct *bz_load(const char *);
250 extern int fd_readable(int);
251 /* In: BZ_SORT.C */
252 extern int sort_quality_decreasing(const void *, const void *);
253 extern int sort_x_y(const void *, const void *);
254 extern int sort_order_decreasing(int [], int, int []);
256 #endif /* !_BOZORTH_H */