Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[4d18a3]: APSCpp / APSCpp_main.c Maximize Restore History

Download this file

APSCpp_main.c    626 lines (536 with data), 21.1 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
/* APSCpp_main.c original 18 Feb2008 TKSharpless
revised 27 July 2009 TKSharpless
Enhanced version of autopano-sift-c. Notable enchancements:
- All-in-one, runs as a plugin under Hugin, no bulky XML files.
- Uses ANN k-d tree implementation, far faster than original,
and float instead of double feature vectors.
- Can read image specifications from Hugin, PTStitcher, PTGui or
PTAssembler project files. Specs include lens type, field of
view, lens correction coefficients and image alignment angles
as well as the file name and dimensions. These are copied to
the output Hugin project file along with the keypoints.
- When able to compute image angular scale, can reproject: to
stereographic for keypoint finding; to spherical for control
point validation; to aligned stereographic for fine keypoint
adjustment.
* (C) Copyright 2004 -- Sebastian Nowozin (nowozin@cs.tu-berlin.de)
*
* "The University of British Columbia has applied for a patent on the SIFT
* algorithm in the United States. Commercial applications of this software
* may require a license from the University of British Columbia."
* For more information, see the LICENSE file supplied with the distribution.
*
* This program is free software released under the GNU General Public
* License, which is included in this software package (doc/LICENSE).
*/
/*
* (C) Copyright 2008, 2009 Thomas K Sharpless (tksharpless@gmail.com)
*
* 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
*
*/
#define APSCPP_VERSION "2.5.2 23July2009" // now separate from package version
#include <time.h>
#include "AutoPanoSift.h"
#include "sphereAlign.h"
// APSCpp.cpp
int LoadProjectImages( char* script, ArrayList * DIlist, bool equalAngle );
KeypointXMLList * GenerateKeyspp( char * imgname, int maxdim,
DIinfo * pdi, double stgfov,
int * KPcount, double globFov );
int MultiMatch_ANN ( MultiMatch* );
void Usage ()
{
WriteLine ("autopano-sift-c: Find control points giving a Hugin project file\n");
WriteLine (" Version %s \n", APSCPP_VERSION);
WriteLine ("autopano-sift-c [options] output.pto image1 image2 [..]");
WriteLine (" hugin project file output.pto gets the results ");
WriteLine (" input images can be jpeg, tiff, or other formats.\n");
WriteLine (" output.pto: The output Hugin project file name, or \"-\" for stdout.");
WriteLine (" image<n>: The input image files (any common format: JPEG, PNG, TIFF,...)");
WriteLine ("autopano-sift-c [options] output.pto projectfile");
WriteLine (" projectfile: a Hugin, PTGui, PTAssembler, PTSticher,... project script with");
WriteLine (" image file names, fields of view, alignments and lens correction");
WriteLine (" factors. Enables stereographic, lens-correction, layout options.");
WriteLine ("");
WriteLine ("Options that affect image processing");
WriteLine (" --maxdim <n> Make largest image dimension <= n (default: 1600).");
WriteLine (" --projection <n>,<d> n = PT format code, d = hfov in degrees, for all images.");
WriteLine (" --equal-angle-fisheye change assumed type for format codes 2,3 from equal-area.");
WriteLine (" --lens-type <1|2|3> set lens type 1: rectlinear ('normal'), 2: equal-area");
WriteLine (" fisheye (common), 3: equal-angle fisheye (uncommon).");
WriteLine (" Used instead of format code default, for all images.");
WriteLine (" --focal-length <mm>,<cf> mm = lens focal length in mm, cf = camera crop factor.");
WriteLine (" Used instead of hfov, for all images.");
WriteLine (" --stereographic <on|off|1|0> reprojection on (if enabled) or off. Default on.");
WriteLine (" Enabled by project file, --projection, --focal-length.");
WriteLine (" --stgfov <d> minimum hfov (degrees) for reprojection. Default 65.");
WriteLine (" --lens-correction <on|off|1|0> correction on (if enabled) or off. Default off.");
WriteLine (" Enabled if project has lens correction coefficients.");
WriteLine ("");
WriteLine ("Options that affect Control Point processing and output");
WriteLine (" --use-layout <on|off|1|0> image alignment in pto file guides control point");
WriteLine (" placement; or does not. Default is off.");
WriteLine (" --maxmatches <matches> Output no more that this many control points per");
WriteLine (" image pair (default: 25, zero means unlimited)");
WriteLine (" --ransac <on|off|1|0> Switch RANSAC filtration on or off (default: off).");
WriteLine (" --integer-coordinates Truncate match coordinates to integer numbers.");
WriteLine (" --absolute-pathnames <on|off|1|0> Use the absolute pathname of the image");
WriteLine (" file in the PTO output file. Disabled by default.");
WriteLine (" --disable-areafilter Do not use max-area filtration, which is default.");
WriteLine ("");
}
typedef struct Resolution Resolution;
struct Resolution
{
int x, y;
};
Resolution* Resolution_new0()
{
Resolution* self = (Resolution*)malloc(sizeof(Resolution));
return self;
}
Resolution* Resolution_new(int x, int y)
{
Resolution* self = Resolution_new0();
self->x = x;
self->y = y;
return self;
}
void Resolution_delete(Resolution* self)
{
if (self) {
free(self);
}
}
int Resolution_CompareTo (Resolution* self, int x, int y)
{
if (self->x == x && self->y == y)
return (0);
return (1);
}
// check a commandline truth value
// return true or false; increment *nerr if invalid
bool YesNoOption (char* optionName, char* val, int * nerr)
{
if (strcmp (val, "1") == 0 || strcmp (val, "on") == 0)
return true;
else if (strcmp (val, "0") == 0 || strcmp (val, "off") == 0)
return false;
WriteLine ("Error '%s' is no valid value for option '%s'.",
val, optionName);
(*nerr)++;
return false;
}
/* mods for APSCpp
new arg DIlist gets * the image info list (++mode) or == 0 (legacy mode)
if ++ mode, copies this info to the output 'i' lines
*/
void WritePTOFile (FILE* pto, MultiMatch* mm,
ArrayList* msList, ArrayList * DIlist,
BondBall* bb, int generateHorizon, bool integerCoordinates,
bool useAbsolutePathnames)
{
DIinfo * pdi = 0;
char buffer[262];
fprintf(pto, "# Stitcher project file generated by APSCpp version %s\n\n", APSCPP_VERSION);
fprintf(pto, "p f2 w3000 h1500 v360 n\"JPEG q90\"\n");
fprintf(pto, "m g1 i0\n\n");
int imageIndex = 0;
HashTable* imageNameTab = HashTable_new0 (NULL, NULL);
ArrayList* resolutions = ArrayList_new0 ( (void *) Resolution_delete);
int i, iks;
for( iks = 0; iks < ArrayList_Count(mm->keySets); iks++ ) {
KeypointXMLList* kx = (KeypointXMLList*) ArrayList_GetItem(mm->keySets, iks );
HashTable_AddItem(imageNameTab, kx->imageFile, (void*)imageIndex);
ArrayList_AddItem(resolutions, Resolution_new (kx->xDim, kx->yDim));
char* imageFile = kx->imageFile;
// get corresponding DIlist record
if( DIlist ){
for( i = 0; i < ArrayList_Count( DIlist ); i++ ){
pdi = (pDIinfo)ArrayList_GetItem( DIlist, i );
if( !strcmp( pdi->name, imageFile ) ) break;
}
if( i >= ArrayList_Count( DIlist ) )
pdi = 0; // NOT FOUND!!
}
// If the resolution was already there, use the first image with
// the exact same resolution as reference for camera-related
// values.
int refIdx;
for (refIdx = 0 ; refIdx < (ArrayList_Count(resolutions) - 1) ; ++refIdx) {
if (Resolution_CompareTo((Resolution*) ArrayList_GetItem(resolutions, refIdx), kx->xDim, kx->yDim) == 0)
break;
}
if (refIdx == (ArrayList_Count(resolutions) - 1))
refIdx = -1;
Position* pos = bb == NULL ? NULL :
(Position*) HashTable_GetItem(bb->positions, imageFile);
/*
if (pos != NULL) {
WriteLine ("yaw %g, pitch %g, rotation %g",
pos->yaw, pos->pitch, pos->rotation);
}*/
double yaw = 0.0, pitch = 0.0, rotation = 0.0, hfov = 180.0;
double a = 0, b = -0.01, c = 0;
int format = 0;
if (pos != NULL) {
yaw = pos->yaw;
pitch = pos->pitch;
rotation = pos->rotation;
} else if( pdi ){
yaw = pdi->yaw;
pitch = pdi->pitch;
rotation = pdi->roll;
format = pdi->format;
if( format == 8 ) format = 3;
hfov = fovdeg( pdi->flpix, kx->xDim, format );
a = pdi->a;
b = pdi->b;
c = pdi->c;
}
if (imageIndex == 0 || refIdx == -1) {
sprintf(buffer, "i w%d h%d f%d a%g b%g c%g d0 e0 p%g r%g v%g y%g u10 n\"%s\"",
kx->xDim, kx->yDim, format, a, b, c, pitch, rotation, hfov, yaw, imageFile);
} else {
sprintf(buffer, "i w%d h%d f%d a=%d b=%d c=%d d0 e0 p%g r%g v=%d y%g u10 n\"%s\"",
kx->xDim, kx->yDim, format, refIdx, refIdx, refIdx, pitch, rotation, refIdx, yaw, imageFile);
}
fprintf( pto, "%s\n", buffer );
//// WriteLine("%s", buffer );
imageIndex += 1;
}
fprintf(pto, "\nv p1 r1 y1\n\n");
fprintf(pto, "# automatically generated control points\n");
int j;
for(j=0; j<ArrayList_Count(msList); j++) {
MatchSet* ms = (MatchSet*) ArrayList_GetItem(msList, j);
int k;
for(k=0; k<ArrayList_Count(ms->matches); k++) {
Match* m = (Match*) ArrayList_GetItem(ms->matches, k);
if (integerCoordinates == false) {
fprintf(pto, "c n%d N%d x%.6f y%.6f X%.6f Y%.6f t0\n",
(int)HashTable_GetItem(imageNameTab, ms->file1), (int)HashTable_GetItem(imageNameTab, ms->file2),
m->kp1->x, m->kp1->y, m->kp2->x, m->kp2->y);
} else {
fprintf(pto, "c n%d N%d x%d y%d X%d Y%d t0\n",
(int)HashTable_GetItem(imageNameTab, ms->file1), (int)HashTable_GetItem(imageNameTab, ms->file2),
(int) (m->kp1->x + 0.5), (int) (m->kp1->y + 0.5),
(int) (m->kp2->x + 0.5), (int) (m->kp2->y + 0.5));
}
}
}
fprintf(pto, "\n# :-)\n\n");
WriteLine ("\nYou can now load the output file into hugin.");
if( DIlist == 0 ){
WriteLine ("Notice: guessed image format and field-of-view, please check and adjust.");
}
ArrayList_delete(resolutions);
HashTable_delete(imageNameTab);
}
int main (int argc, char* argv[])
{
clock_t start,finish;
double time;
// list used in ++ mode only -- image info from pto file
ArrayList * DIlist = 0; // item = DIinfo struct.
char *projectfile = 0;
int Nerr = 0; // counts commandline errors
// "--projection" option
int globFmt = -1; // default PT format code
double globFov = 0; // width for all images in degrees
// downscale option = largest allowed image dimension (0: none)
int maxdim = 1600;
// output to stdout flag
bool streamout = false;
// Use RANSAC algorithm match filtration.
bool useRansac = false;
// Use stereographic projection if feasible
bool useStereographic = true;
double stgfov = 65; // don't reproject below this hfov
// Lens and camera settings, valid if > 0
double FLmm = 0,
cropFactor = 0;
int lensType = 0;
// Use project alignment if feasible
bool useLayout = false;
// Use project lens correction fn if feasible
bool lensCorrection = false;
// treat fisheye lens as equal-angle
bool equalAngle = false;
// Use area based weighting for final match selection.
bool useAreaFiltration = true;
// Truncate match coordinates to integer numbers.
bool useIntegerCoordinates = false;
// Use the absolute pathname of the image files in the output PTO
// file.
bool useAbsolutePathnames = false;
// Use "keep-best" filtration, keep the maxMatches best.
int maxMatches = 25; // default
int optionCount = 0;
int optionN = 1;
int i;
int totalKPs = 0;
WriteLine ("\nAPSCpp, enhanced autopano-sift-c version %s \n", APSCPP_VERSION);
LoweFeatureDetector_SetVerbose(false); // default low chatter
if (argc+1 < 3) { // can't be legal commandline
Usage ();
exit (1);
}
while (optionN < argc &&
strlen(argv[optionN]) >= 2
&& argv[optionN][0] == '-'
&& argv[optionN][1] == '-')
{
char* optionStr = argv[optionN];
int joptN = 1; // number of args processed
if (strcmp (optionStr, "--maxdim") == 0) {
joptN = 2;
maxdim = atoi(argv[optionN + 1]);
} else if( strcmp (optionStr, "--projection") == 0) {
joptN = 2;
char *p = argv[optionN + 1];
if(sscanf( p, "%d", &globFmt ) != 1 ){
WriteLine ("Parameter to projection option invalid. See the usage help.");
++Nerr;
}
p = strchr(p,',');
if( p ) globFov = atof(p+1);
else {
WriteLine ("Parameter to projection option invalid. See the usage help.");
++Nerr;
}
} else if( strcmp (optionStr, "--focal-length") == 0) {
joptN = 2;
char *p = argv[optionN + 1];
if(sscanf( p, "%g", &FLmm ) != 1 ){
WriteLine ("Invalid focal length");
++Nerr;
}
p = strchr(p,',');
if( !p || sscanf( p, "%g", &cropFactor ) != 1 )
{
WriteLine ("Invalid crop factor");
++Nerr;
}
} else if (strcmp (optionStr, "--ransac") == 0) {
joptN = 2;
useRansac = YesNoOption ("--ransac", argv[optionN + 1], &Nerr );
} else if (strcmp (optionStr, "--stgfov") == 0) {
joptN = 2;
stgfov = atof( argv[optionN + 1] );
} else if (strcmp (optionStr, "--stereographic") == 0) {
joptN = 2;
useStereographic = YesNoOption ("--stereographic", argv[optionN + 1], &Nerr );
} else if (strcmp (optionStr, "--use-layout") == 0) {
joptN = 2;
useLayout = YesNoOption ("--use-layout", argv[optionN + 1], &Nerr );
} else if (strcmp (optionStr, "--lens-correction") == 0) {
joptN = 2;
lensCorrection = YesNoOption ("--lens-correction", argv[optionN + 1], &Nerr );
} else if (strcmp (optionStr, "--lens-type") == 0) {
joptN = 2;
if( sscanf( argv[optionN + 1], "%d", &lensType) != 1
|| lensType < 1 || lensType > 3 ){
WriteLine ("Invalid --lens-type.");
++Nerr;
}
} else if (strcmp (optionStr, "--maxmatches") == 0) {
joptN = 2;
if (sscanf(argv[optionN + 1], "%d", &maxMatches) != 1) {
WriteLine ("Invalid --maxmatches.");
++Nerr;
}
if (maxMatches < 0) {
WriteLine ("Maximum number of matches must be positive or zero (unlimited).");
++Nerr;
}
} else if (strcmp (optionStr, "--disable-areafilter") == 0) {
useAreaFiltration = false;
} else if (strcmp (optionStr, "--equal-angle-fisheye") == 0) {
equalAngle = true;
} else if (strcmp (optionStr, "--integer-coordinates") == 0) {
useIntegerCoordinates = true;
} else if (strcmp (optionStr, "--absolute-pathnames") == 0) {
joptN = 2;
useAbsolutePathnames = YesNoOption ("--absolute-pathnames", argv[optionN + 1], &Nerr);
} else {
WriteLine ("Bad option \"%s\"", optionStr);
++Nerr;
break; // let's not take chances....
}
optionN += joptN;
}
optionCount = optionN;
// is there an output name and at least one input name?
if( argc - optionN < 2 ){
WriteLine ("Error. Output name and at least one more name required.");
++Nerr;
}
// show usage and quit if commandline errors
if (Nerr){
WriteLine ("%d commandline errors.\n", Nerr );
Usage();
exit( 1 );
}
// next arg is either output file name or "-" for stdout
// anything else beginning with '-' is an error
if( argv[optionCount][0] == '-' ){
if( strcmp( argv[optionCount], "-" ) == 0 )streamout = true;
else {
WriteLine ("Misplaced option '%s'.\n", argv[optionCount] );
Usage();
exit (1);
}
}
/* next arg is either a script name or the first of 2 or more image file names
*/
if( argc - optionCount == 2 ){
projectfile = argv[optionCount + 1];
WriteLine("Reading project file %s", projectfile );
// enable ++ mode by creating DIlist
DIlist = ArrayList_new0( (void *) DIinfo_delete );
// read the proect file image info into DIlist, or die
if( LoadProjectImages( argv[optionCount + 1], DIlist, equalAngle ) == 0 ){
WriteLine ("Error reading project file.");
exit(1);
}
} else if( globFmt >= 0 && globFov > 0 ){
// enable ++ mode
DIlist = ArrayList_new0( (void *) DIinfo_delete );
}
/** set up and report options **/
if( !DIlist ){
lensCorrection = false;
useLayout = false;
if( globFmt < 0 && FLmm == 0 ) useStereographic = false;
}
if( lensType ){
WriteLine(" Assuming %s lens type.",
lensType == 1 ? "rectilinear"
: lensType == 2 ? "equal-area fisheye"
: "equal-angle fisheye" );
} else {
WriteLine(" Default fisheye lens type is %s.",
equalAngle ? "equal-angle" : "equal-area" );
}
if( FLmm && cropFactor ){
WriteLine(" Assuming focal length %.2f mm, crop factor %.4f.",
FLmm, cropFactor);
} else {
WriteLine(" Focal length will be computed from hfov.");
}
if( useStereographic )
WriteLine(" Stereographic projection enabled for hfov >= %.1f degrees.", stgfov );
if( lensCorrection )
WriteLine(" Lens correction enabled BUT NOT IMPLEMENTED.");
if( useLayout )
WriteLine(" Layout guided CP placement enabled BUT NOT IMPLEMENTED.");
/** Find keypoints **/
start = clock();
ArrayList* keylists = ArrayList_new0(NULL);
if( DIlist ){
// ++ mode: image info from DIlist
pDIinfo pd;
// build it first if only a global projection was given
if( globFmt >= 0 ){
for( i=0; i<argc - 1 - optionCount; i++) {
pd = DIinfo_new0();
pd->format = globFmt;
pd->flpix = 0;
strcpy(pd->name, argv[i+optionCount+1] );
// note dimensions are still zero
ArrayList_AddItem( DIlist, pd );
}
}
// process the images
for( i = 0; i < ArrayList_Count( DIlist ); i++ ){
pd = (pDIinfo) ArrayList_GetItem( DIlist, i);
if( !DIinfo_isDummy( pd ) )
ArrayList_AddItem( keylists,
GenerateKeyspp( pd->name, maxdim, pd,
useStereographic ? stgfov : -1,
&totalKPs, globFov ) );
}
} else {
// std mode: image names only from commandline
for( i=0; i<argc - 1 - optionCount; i++) {
ArrayList_AddItem( keylists,
GenerateKeyspp( argv[i+optionCount+1],
maxdim, 0, 0, &totalKPs,
globFov ) );
}
}
finish = clock();
time = ((double)finish - (double)start ) / CLOCKS_PER_SEC;
WriteLine("%.1f seconds to find keypoints", time);
// fail if no keypoints were found
if( totalKPs < 2 ){
FatalError("No keypoints found!");
}
/** Find control points **/
start = clock();
MultiMatch* mm = MultiMatch_new0 ();
MultiMatch_LoadKeysetsFromMemory (mm, keylists);
// note mm now owns keylists and will delete it when destroyed
WriteLine ("\nMatching; ransac %s, area filter %s, layout %s ...",
useRansac == true ? "on" : "off",
useAreaFiltration == true ? "on" : "off",
useLayout == true ? "on" : "off"
);
MultiMatch_ANN ( mm );
ArrayList* msList = MultiMatch_LocateMatchSets (mm, 3, maxMatches,
useRansac, useAreaFiltration);
finish = clock();
time = ((double)finish - (double)start ) / CLOCKS_PER_SEC;
WriteLine("\n%.1f seconds to match keypoints", time);
// Connected component check
WriteLine ("\nConnected component check...");
ArrayList* components = MultiMatch_ComponentCheck (mm, msList);
WriteLine ("Connected component identification resulted in %d component%s:",
ArrayList_Count(components), ArrayList_Count(components) > 1 ? "s" : "");
int compN = 1;
int j;
for(j=0; j<ArrayList_Count(components); j++) {
Component* comp = (Component*) ArrayList_GetItem(components, j);
char* compstr = Component_ToString(comp);
WriteLine ("component %d: %s", compN++, compstr);
free(compstr);
}
if (ArrayList_Count(components) > 1) {
WriteLine ("");
WriteLine ("Warning: One or more components are not connected through control points.");
WriteLine (" Optimization of the resulting PTO will not be possible without");
WriteLine (" manual addition of control points between the components listed");
WriteLine (" above. Please see the manual page for autopano(1) for details.");
WriteLine ("");
} else
WriteLine ("");
FILE* pto;
if ( streamout ) {
pto = stdout;
} else {
WriteLine ("Creating output file \"%s\"", argv[optionCount]);
pto = fopen(argv[optionCount], "w");
}
WritePTOFile (pto, mm, msList, DIlist,
0, 0, useIntegerCoordinates,
useAbsolutePathnames);
ArrayList_delete(components);
MultiMatch_delete(mm);
if ( !streamout )
fclose(pto);
return 0;
}