[ba04a1]: APSCpp / APSCpp.c Maximize Restore History

Download this file

APSCpp.c    695 lines (601 with data), 20.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
/* APSCpp.cpp 04 Mar 2008 TKS
various routines for enhanced autopano-sift-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 software 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 software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "AutoPanoSift.h"
#include "sphereAlign.h"
#include "saInterp.h"
#include <math.h>
#include <tiffio.h>
// create empty
pDIinfo DIinfo_new0(){
pDIinfo p = (pDIinfo)malloc(sizeof(DIinfo));
if( p ) memset( p, 0, sizeof(DIinfo) );
return p;
}
// delete
void DIinfo_delete( pDIinfo p ){
free( p );
}
bool DIinfo_isDummy( pDIinfo self ){
return self->name[0] == 0;
}
/*
Get source image info from a panotools project file.
revised 19 July 2009 to read PTAsm/PTGui file names
Adapted from "optimizer script parser" in panotools\parser.c
Should work with panotools, ptasmblr and hugin projects.
Ignores everything except 'i' lines (unless there are none,
when it scans the file again looking for 'o' lines) and the
structured comment lines (#-imgfile wid hgt "path") used by
PTGui and PTAssembler to hold file names. Such lines precede
the 'i' or 'o' line that holds the image parameters.
input
project file name
output
adds a DisplayImage struct to DIlist for each "i" or "o" line
with only the following fields set
name
width
height
hfov
format
yaw
pitch
roll
returns
0 on error else number of image lines found
Notes
ignores all optimizable params except hfov, y, p, r;
handles back references ("v=n", etc) by copying the value from
the referenced image.
accepts all format codes verbatim (original checks them)
*/
#define LINE_LENGTH 512
#define READ_VAR( fmt, ref ) \
sscanf( ++li, fmt, ref ); \
if( *li == '"' ) do ++li; while(*li != '"'); \
while(*li > ' ') li++;
int LoadProjectImages( char* script, ArrayList * DIlist, bool equalAngle )
{
DIinfo *im, *ir; // DIlist items
// Variables used by parser
char *li, line[LINE_LENGTH], *ch;
int lineNum = 0;
int k;
int numIm = 0;
int baseIdx = ArrayList_Count( DIlist ); // 1st image goes here
int FNflag; // 0: no #-imgfile line since last i or o
// >0: have read this many
int imwid, imhgt;
int keychar;
bool PTGui = false, PTAsm = false, Hugin = false;
char namebuf[300];
double hfov;
im = 0; // flag: no info read
// setlocale(LC_ALL, "C");
// loop over 'i', 'o' linestart
for( keychar = 'i';; ){
FILE * fp = fopen( script, "r" );
if( !fp ) return 0;
// Parse script
while( (ch = fgets(line, LINE_LENGTH, fp)) )
{
if( !PTGui && !PTAsm && !Hugin ){
if( !strncmp( line, "# ptGui project file", 20 )) PTGui = true;
else if( !strncmp( line, "# Script file for PTAStitcher", 29 )) PTAsm = true;
else if( !strncmp( line, "# hugin project file", 20 )) Hugin = true;
}
lineNum++;
if( !strncmp( line, "#-imgfile ", 10 )){
if( sscanf( line + 10, "%d %d %s", &imwid, &imhgt, namebuf ) == 3 ){
++FNflag;
if( namebuf[0] == '"' ){
register char * p = namebuf + 1;
while( *p != '"'){ p[-1] = p[0]; ++p; }
p[-1] = 0;
}
}
} else if( line[0] == keychar
&& isspace( line[1] ) )
{
// create new Image descriptor
im = DIinfo_new0();
// fill it from line
li = &(line[1]);
while( *li != 0 && *li != '\n')
{
switch(*li)
{
case 'a': if( *(li+1) == '=' ){ // copy referenced value
++li;
READ_VAR( "%d", &k )
ir = (DIinfo *)ArrayList_GetItem( DIlist, baseIdx + k );
im->a = ir->a;
} else READ_VAR("%lf", &(im->a));
break;
case 'b': if( *(li+1) == '=' ){ // copy referenced value
++li;
READ_VAR( "%d", &k )
ir = (DIinfo *)ArrayList_GetItem( DIlist, baseIdx + k );
im->b = ir->b;
} else READ_VAR("%lf", &(im->b));
break;
case 'c': if( *(li+1) == '=' ){ // copy referenced value
++li;
READ_VAR( "%d", &k )
ir = (DIinfo *)ArrayList_GetItem( DIlist, baseIdx + k );
im->c = ir->c;
} else READ_VAR("%lf", &(im->c));
break;
case 'w': READ_VAR( "%d", &(im->width) )
break;
case 'h': READ_VAR( "%d", &(im->height))
break;
case 'v': if( *(li+1) == '=' ){ // copy referenced value
++li;
READ_VAR( "%d", &k )
ir = (DIinfo *)ArrayList_GetItem( DIlist, baseIdx + k );
hfov = fovdeg( ir->flpix, ir->width, ir->fmtref);
}else{
READ_VAR( "%lf", &hfov);
}
break;
case 'f':
READ_VAR( "%d", &(im->format) );
// convert PTAsm equal-area fisheye code to local code
im->fmtref = im->format == 29 ? 8 : im->format;
break;
case 'y': if( *(li+1) == '=' ){
// copy referenced value
++li;
READ_VAR( "%d", &k )
ir = (DIinfo *)ArrayList_GetItem( DIlist, baseIdx + k );
im->yaw = ir->yaw;
}else{
READ_VAR( "%lf", &(im->yaw));
}
break;
case 'p': if( *(li+1) == '=' ){
// copy referenced value
++li;
READ_VAR( "%d", &k )
ir = (DIinfo *)ArrayList_GetItem( DIlist, baseIdx + k );
im->pitch = ir->pitch;
}else{
READ_VAR("%lf", &(im->pitch));
}
break;
case 'r': if( *(li+1) == '=' ){
// copy referenced value
++li;
READ_VAR( "%d", &k )
ir = (DIinfo *)ArrayList_GetItem( DIlist, baseIdx + k );
im->roll = ir->roll;
}else{
READ_VAR("%lf", &(im->roll));
}
break;
case 'n': // Set filename (Hugin & PTools)
{ char *p = im->name;
// assume always quoted
READ_VAR("\"%[^\"]\"", p);
}
break;
default:
break;
}
while( *li > ' ' ){ // skip next "word"
if( *li == '"' ) do ++li; while( *li != '"' ); // quoted strings
++li;
}
if(*li) li++; // skip one nonnull
} // EOL
// check name, patch in PTAsm/PTGui file name
if( im && DIinfo_isDummy( im ) ){
if( FNflag ){
strcpy( im->name, namebuf );
im->width = imwid;
im->height = imhgt;
}
FNflag = 0;
}
if( im ){
/* add this image info to list
but first, post focal length in pixels
and the working format code
PTAsm allows to specify fisheye as either equal angle (format codes 2,
3)or equal area (code29, which we convert to 8). PTGui assumes all
fisheyes are equal-area, Hugin assumes they are equal-angle. APSCpp
lets you override those assumptions by setting equalAngle true or false.
*/
int w = im->width;
int fmt = im->fmtref;
/* PTGui circular fisheye fov is crop circle diameter. Since
we don't know what that is in pixels, assume it is equal to
the long image axis....
*/
if( PTGui && fmt == 2 && im->height > im->width)
w = im->height;
if((fmt == 2 || fmt == 3) ){ // fisheye formats...
if( PTGui ) fmt = 8; // PTGuis assumes equal-area
// post user preferred format for processing
if( !equalAngle ) im->format = 8;
}
else if( im->format == 29 ) im->format = 8;
// compute focal length as originator did
im->flpix = flpix( hfov, w, fmt );
// list the image
numIm++;
ArrayList_AddItem( DIlist, im );
im = 0; // flag: no current info line
}
} // end of line
} // end of file
FNflag = 0;
fclose( fp );
if( numIm > 0 || keychar == 'o' ) break;
keychar = 'o'; // try again...
}
return numIm;
}
/* Dump an ImagMap to a tiff file
return success or failure
*/
int ImageMap_toTIFF( ImageMap * p, char * name )
{
int i, ok = 0;
// create tiff file
TIFF * tp = TIFFOpen( name, "w" );
if( !tp ) return 0;
// set tiff tags
TIFFSetField( tp, TIFFTAG_IMAGEWIDTH, p->yDim );
TIFFSetField( tp, TIFFTAG_IMAGELENGTH, p->xDim );
TIFFSetField( tp, TIFFTAG_PLANARCONFIG, 1 ); // packed pixels
TIFFSetField( tp, TIFFTAG_ROWSPERSTRIP, 1 ); // separate rows
TIFFSetField( tp, TIFFTAG_COMPRESSION, 1 ); // uncompressed
TIFFSetField( tp, TIFFTAG_SAMPLESPERPIXEL, 1 ); // monochrome
TIFFSetField( tp, TIFFTAG_PHOTOMETRIC, 1 ); // greyscale
TIFFSetField( tp, TIFFTAG_BITSPERSAMPLE, 32 );
TIFFSetField( tp, TIFFTAG_SAMPLEFORMAT, 3 ); // IEEE float
// write the data rowwise
for( i = 0; i < p->xDim; i++ ){
if((ok = TIFFWriteScanline( tp, p->values[i], i, 0 )) != 1 ) break;
}
// done
TIFFClose( tp );
return ok;
}
/* subroutine equivalent to GenerateKeys.c
for APSC++, new argumnent pdi -> DIinfo struct with the input
projection format and angular width into needed to set up a
remapping to stereographic format. If pdi is 0, behaves like
GenerateKeys() with these exceptions.
1) it sets the Lowe routine's prefilter sigma to 0.5 if the image stays
at original size, or to 0 (no further smoothing) if it is reduced here.
2) it always reduces image size (when maxdim < largest input dimension)
by a smooth interpolation rather than simple decimation.
3) it never invokes the Lowe detector's option to expand the image 2x.
returns 0 for failure
06 Mar 2008 new mode argument.
0 for legacy (KDTree) mode -- returns list of KeypointN
1 for ANN mode -- returns list of Keypoint
removed 19 July 2009, legacy k-d tree is no longer an option
18 July 2009 new stgfov argument
<0 forbids reprojection
>=0 allows reprojection when hfov exceeds this value
26 July 2009 add argument globFov, used when pdi is null.
*/
///#define _DEBUG_INTERP
KeypointXMLList * GenerateKeyspp( char * imgname, int maxdim, DIinfo * pdi,
double stgfov, int * KPcount, double globFov )
{
#ifdef _DEBUG_INTERP
char tmp[262];
#endif
int nKeys;
int pW, pH;
double Xcen, Ycen;
saRemap *prm = 0;
ImageMap* picMap = 0;
LoweFeatureDetector* lf;
KeypointXMLList* kpp;
double Scale = 1.0;
double xcen, ycen; // scaled center
double hfov = 0;
// reduce Lowe prefilter smoothing
double savesigma = LoweFeatureDetector_SetPreprocSigma( 0.5 );
/* read the image */
DisplayImage* pic = DisplayImage_new(imgname);
// (if we get here the image was read OK, and its name printed)
if(!pdi) {
hfov = globFov;
WriteLine(" width %d height %d", pic->width, pic->height );
} else {
// If globFov is non null, its value was specified by
// the user on the command line, so use that.
if (globFov > 0.0) {
hfov = globFov;
// Also set pdi->flpix as this is used when writing
// the pto to calculate fov
pdi->flpix = flpix(hfov, pic->width, pdi->format );
} else
hfov = fovdeg( pdi->flpix, pic->width, pdi->format );
WriteLine(" %s width %d height %d hfov %g ",
formatName( pdi->format), pic->width, pic->height, hfov);
// put actual image dimensions in the DIinfo, just in case...
pdi->width = pic->width; pdi->height = pic->height;
}
pW = pic->width;
pH = pic->height;
xcen = Xcen = 0.5 * pW;
ycen = Ycen = 0.5 * pH;
// convert to monochrome float and discard input image
picMap = DisplayImage_ConvertToImageMap( pic );
DisplayImage_delete(pic);
#ifdef _DEBUG_INTERP
strcpy(tmp, imgname);
strcat(tmp,"-MAP.TIF");
ImageMap_toTIFF( picMap, tmp );
#endif
/* reduce size if required
by interpolating in smoothed map
also convert to stereographic if pdi is valid
*/
// prescale factor
if( maxdim > 0) Scale = ( pW > pH ? pW : pH ) / (double) maxdim;
if( Scale <= 1 ) Scale = 1;
// interpolate if necessary
if( pdi || Scale > 1 ){
ImageMap * pn;
int x, y;
double X, Y;
int dwid = pW, dhgt = pH;
// reduced dimensions
if( Scale > 1 ){
// scaled dimensions
dwid = (int)( pW / Scale ); xcen = 0.5 * dwid;
dhgt = (int)( pH / Scale ); ycen = 0.5 * dhgt;
// exact scale factor
if( pW > pH ) Scale = (double) pW / (double) dwid;
else Scale = (double) pH / (double) dhgt;
WriteLine(" reduce to %d x %d (Scale %.4f)...", dwid, dhgt, Scale );
// smooth the source for antialiasing
ImageMap* tmp = ImageMap_GaussianConvolution( picMap, 0.75 * Scale );
ImageMap_delete( picMap );
picMap = tmp;
}
// create result map
pn = ImageMap_new( dwid, dhgt );
LoweFeatureDetector_SetPreprocSigma( 0 );
// set up stereographic mapping
if( pdi && stgfov >= 0 && hfov >= stgfov ){
CamLens * psp, * pdp;
// create the projections
psp = CamLens_new1( pW, pH, pdi->format, hfov, 16.0 );
pdp = CamLens_new1( dwid, dhgt, _stereographic, hfov, 0 );
// create the mapping
prm = saRemap_new( psp, pdp );
saRemap_inv ( prm, 0.5 * dwid, 0.5 * dhgt, &Xcen, &Ycen );
WriteLine(" convert to stereographic projection ...");
CamLens_delete( psp );
CamLens_delete( pdp );
}
// interpolate
saInterpSetup((void *)picMap->values, // void * pdata
2, // format is column vectors
picMap->xDim, // int wid,
picMap->yDim, // int hgt,
1, // samples per pixel
picMap->xDim, // pixels per row
0, // char wrap, // required
0, // char * pmask,
0, 0, 0 // mask params
);
for( x = 0; x < pn->xDim; x++ ){
float * pd = pn->values[x];
for( y = 0; y < pn->yDim; y++ ){
X = (double) x; Y = (double) y;
if( prm ) saRemap_inv ( prm, X, Y, &X, &Y ); // ++
else { // linear rescale...
// note no need to subtract and re-add center, that just adds noise
X *= Scale; Y *= Scale;
}
saInterp_float( &(pd[y]), X, Y );
}
}
// swap
ImageMap_delete( picMap );
picMap = pn;
saRemap_delete( prm ); prm = 0;
#ifdef _DEBUG_INTERP
strcpy(tmp, imgname);
strcat(tmp,"-MAP-PROJ.TIF");
ImageMap_toTIFF( picMap, tmp );
WriteLine("ImageMap dumped to %s", tmp );
exit(0);
#endif
}
/* find the features
Note feature point coords are at source scale
*/
WriteLine(" find keypoints ..." );
lf = LoweFeatureDetector_new0();
nKeys = LoweFeatureDetector_DetectFeaturesDownscaled (lf, picMap, 0, Scale);
WriteLine(" %d keypoints found\n", nKeys );
*KPcount = nKeys;
/* build the return value. For APSCPP this is a list of keypoint (float
feature vector) not of keypointN (char feature vector). The feature
detector returns KP coordinates at source scale, so here all we need
to do is undo the stereographic projection if one was done.
*/
{
// ArrayList * globalNaturalKeypoints = 0;
int i;
if( pdi && stgfov >= 0 && hfov >= stgfov ){
// build remapping function at source scale
CamLens * psp, * pdp;
psp = CamLens_new1( pW, pH, pdi->format, hfov, 16.0 );
pdp = CamLens_new1( pW, pH, _stereographic, hfov, 0 );
prm = saRemap_new( psp, pdp ); // dest=>src
CamLens_delete( psp );
CamLens_delete( pdp );
} else prm = 0;
for(i=0; i < ArrayList_Count(lf->globalKeypoints); i++) {
Keypoint* kp = (Keypoint *) ArrayList_GetItem( lf->globalKeypoints, i );
if( prm ){ // remap coordinates to image projection
saRemap_inv ( prm,
kp->x , kp->y ,
&kp->x, &kp->y
);
}
}
// package the list
kpp = KeypointXMLList_new0();
kpp->imageFile = strdup(imgname);
kpp->xDim = pW;
kpp->yDim = pH;
// return the Keypoint list
kpp->array = lf->globalKeypoints;
lf->globalKeypoints = 0; // don't delete the list!
}
// delete the LoweDetector
LoweFeatureDetector_delete(lf);
// restore the default Lowe prefilter
LoweFeatureDetector_SetPreprocSigma( savesigma );
// disable the patent warning message for any subsequent images
LoweFeatureDetector_SetPrintWarning(false);
return kpp;
}
/* Match keypoints with ANN kd-tree
argument is a MultiMatch loaded with Keypoints
returns with matchlist filled in and the Keypoints
replaced by KeypointN n both keySets and globalKeys
(caution these point to same KeypointN's)
returns number of matches, or 0 on error
*/
#ifdef __cplusplus
extern "C" {
#endif
// wrapper fns in ANNkd_wrap.cpp
void ANNkd_new( int sd, double **pts, int n, int d );
void ANNkd_search( double * pt, int nnabe, int *indx, double *dist, double nneps );
void ANNkd_delete( void );
#ifdef __cplusplus
}
#endif
int MultiMatch_ANN ( MultiMatch* self ){
// nearest neighbor search parameters
#define nnabe 2 // only need 2, self-match is disabled in ANN
#define nneps 0.0
#define mindepth 180 // Nowozin tree uses 130
// search results
double dist[nnabe]; // an array of squared distances
int indx[nnabe]; // an array of point indices
int m = 0; // return value
int i, j, k, n, d;
Keypoint * kp = 0;
// count keypoints
n = 0; // number of keypoints
for(i=0; i<ArrayList_Count(self->keySets); i++) {
KeypointXMLList* list = (KeypointXMLList*) ArrayList_GetItem(self->keySets, i);
n += ArrayList_Count( list->array );
}
/* make array of pointers to coordinates rq'd by ANN
and array of pointers to corresponding keypointN.s
*/
double ** pts = (double **)malloc( n * sizeof(double **));
KeypointN ** kpn = (KeypointN **)malloc( n * sizeof(KeypointN **));
// fill pts with pointers to Keypoint feature vectors
// and kpn with pointers to equivalent KeypointNs
k = 0;
for(i=0; i<ArrayList_Count(self->keySets); i++) {
KeypointXMLList* list = (KeypointXMLList*) ArrayList_GetItem(self->keySets, i);
for(j=0; j<ArrayList_Count(list->array); j++) {
kp = (Keypoint*) ArrayList_GetItem(list->array, j);
pts[k] = kp->featureVector;
// Make the KeypointN
kpn[k++] = KeypointN_new( kp );
}
}
if( k < 1 ) return 0;
d = kp->featureVectorLength; // # of dimensions
// search cutoff depth
int sd = (int)( mindepth * max( 1.0, log ((double) n) / log (1000.0) ));
/* build the kd-tree
*/
ANNkd_new( sd, pts, n, d );
if (self->verbose){
WriteLine ("ANN kd-tree: %d keypoints, cutoff depth %d", n, sd);
}
// find near neighbors of each key
k = 0;
for( i = 0; i < n; i++ ) {
// report progress
if (self->verbose) {
if ((i % 500) == 0)
Write ("\r%2.2f%%, %d/%d ",
(100 * ((double) i)) / ((double) n),
i, n);
}
// find neighbors
ANNkd_search( pts[i], nnabe, indx, dist, nneps );
/* add valid neighbor pairs to global matches list
NOTE Matches point to KeypointN's made above
NOTE ANN returns squared distances
Nowozin accepts only the first neighbor as a match, and only if it is
significantly nearer than the 2nd neighbor. His Match structure includes
both distances.
The code below disallows matches to points that have already been tested.
That prevents all duplicate matches, at the cost of losing possible control
points shared by 3 or more images -- but Nowozin's method loses those too.
*/
if( indx[0] > i && dist[0] / dist[1] < 0.36 ){
ArrayList_AddItem( self->globalMatches,
Match_new (kpn[i], kpn[indx[0]],
sqrt(dist[0]), sqrt(dist[1]))
);
m++;
}
}
if (self->verbose) {
Write ("\r %2.2f%%, %d/%d ",
(100 * ((double) i)) / ((double) n),
i, n );
WriteLine ("\nGlobal match search yielded %d matches", m );
}
/* Replace Keypoints with KeypointNs in keySets
NOTE globalKeys list is not needed as only KDTree code uses it
*/
k = 0;
for(i=0; i<ArrayList_Count(self->keySets); i++) {
KeypointXMLList* list = (KeypointXMLList*) ArrayList_GetItem(self->keySets, i);
for(j=0; j<ArrayList_Count(list->array); j++) {
kp = (Keypoint*) ArrayList_GetItem(list->array, j);
ArrayList_SetItem( list->array, j, (void *)kpn[k] );
//// Not needed ArrayList_AddItem( self->globalKeys, (void *)kpn[k] );
k++;
Keypoint_delete( kp );
}
}
// tidy
free( pts );
free( kpn );
ANNkd_delete();
return m;
}