[6d12f1]: / src / hugin1 / hugin / PanoOperation.cpp  Maximize  Restore  History

Download this file

1338 lines (1230 with data), 42.2 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
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
// -*- c-basic-offset: 4 -*-
/** @file PanoOperation.cpp
*
* @brief Implementation of PanoOperation class
*
*/
/* 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 "hugin/PanoOperation.h"
#include "hugin/config_defaults.h"
#include "hugin/wxPanoCommand.h"
#include "huginapp/ImageCache.h"
#include "base_wx/MyProgressDialog.h"
#include "base_wx/PTWXDlg.h"
#include "algorithms/optimizer/ImageGraph.h"
#include "algorithms/control_points/CleanCP.h"
#include "celeste/Celeste.h"
#include <exiv2/exif.hpp>
#include <exiv2/image.hpp>
#include "base_wx/LensTools.h"
#include "base_wx/wxLensDB.h"
#include "hugin/ResetDialog.h"
#include "hugin/MainFrame.h"
using namespace HuginBase;
namespace PanoOperation
{
wxString PanoOperation::GetLabel()
{
return wxEmptyString;
};
bool PanoOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
return true;
};
PT::PanoCommand* PanoOperation::GetCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
//remember gui level, only used by some PanoOperation's
m_guiLevel=guiLevel;
if(IsEnabled(pano, images, m_guiLevel))
{
return GetInternalCommand(parent,pano,images);
}
else
{
return NULL;
};
};
bool PanoSingleImageOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
return images.size()==1;
};
bool PanoMultiImageOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
return images.size()>0;
};
/** small function to show add image dialog
* @param parent pointer to window, for showing dialog
* @param files vector, to which the selected valid filenames will be added
* @returns true, if a valid image was selected, otherwise false
*/
bool AddImageDialog(wxWindow* parent, std::vector<std::string>& files)
{
// get stored path
wxConfigBase* config = wxConfigBase::Get();
wxString path = config->Read(wxT("/actualPath"), wxT(""));
wxFileDialog dlg(parent,_("Add images"),
path, wxT(""),
HUGIN_WX_FILE_IMG_FILTER,
wxFD_OPEN | wxFD_MULTIPLE, wxDefaultPosition);
dlg.SetDirectory(path);
// remember the image extension
wxString img_ext;
if (config->HasEntry(wxT("lastImageType")))
{
img_ext = config->Read(wxT("lastImageType")).c_str();
}
if (img_ext == wxT("all images"))
dlg.SetFilterIndex(0);
else if (img_ext == wxT("jpg"))
dlg.SetFilterIndex(1);
else if (img_ext == wxT("tiff"))
dlg.SetFilterIndex(2);
else if (img_ext == wxT("png"))
dlg.SetFilterIndex(3);
else if (img_ext == wxT("hdr"))
dlg.SetFilterIndex(4);
else if (img_ext == wxT("exr"))
dlg.SetFilterIndex(5);
else if (img_ext == wxT("all files"))
dlg.SetFilterIndex(6);
// call the file dialog
if (dlg.ShowModal() == wxID_OK)
{
// get the selections
wxArrayString Pathnames;
dlg.GetPaths(Pathnames);
// remember path for later
#ifdef __WXGTK__
//workaround a bug in GTK, see https://bugzilla.redhat.com/show_bug.cgi?id=849692 and http://trac.wxwidgets.org/ticket/14525
config->Write(wxT("/actualPath"), wxPathOnly(Pathnames[0]));
#else
config->Write(wxT("/actualPath"), dlg.GetDirectory());
#endif
// save the image extension
switch (dlg.GetFilterIndex())
{
case 0: config->Write(wxT("lastImageType"), wxT("all images")); break;
case 1: config->Write(wxT("lastImageType"), wxT("jpg")); break;
case 2: config->Write(wxT("lastImageType"), wxT("tiff")); break;
case 3: config->Write(wxT("lastImageType"), wxT("png")); break;
case 4: config->Write(wxT("lastImageType"), wxT("hdr")); break;
case 5: config->Write(wxT("lastImageType"), wxT("exr")); break;
case 6: config->Write(wxT("lastImageType"), wxT("all files")); break;
}
//check for forbidden/non working chars
wxArrayString invalidFiles;
for(unsigned int i=0;i<Pathnames.GetCount(); i++)
{
if(containsInvalidCharacters(Pathnames[i]))
{
invalidFiles.Add(Pathnames[i]);
};
};
if(invalidFiles.size()>0)
{
ShowFilenameWarning(parent, invalidFiles);
return false;
}
for (unsigned int i=0; i<Pathnames.GetCount(); i++)
{
files.push_back((const char *)Pathnames[i].mb_str(HUGIN_CONV_FILENAME));
};
return true;
};
return false;
};
wxString AddImageOperation::GetLabel()
{
return _("Add individual images...");
};
PT::PanoCommand* AddImageOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
std::vector<std::string> files;
if(AddImageDialog(parent, files))
{
if(files.size()>0)
{
return new PT::wxAddImagesCmd(pano,files);
};
};
return NULL;
};
WX_DECLARE_STRING_HASH_MAP(time_t, StringToPointerHash);
WX_DECLARE_STRING_HASH_MAP(int, StringToFlagHash);
time_t ReadExifTime(const char* filename)
{
Exiv2::Image::AutoPtr image;
try
{
image = Exiv2::ImageFactory::open(filename);
}
catch(...)
{
return 0;
}
if (image.get() == 0)
{
return 0;
}
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
if (exifData.empty())
{
return 0;
}
Exiv2::Exifdatum& tag = exifData["Exif.Image.DateTime"];
const std::string date_time = tag.toString();
// Remember the file and a shutter timestamp.
struct tm when;
memset(&when, 0, sizeof(when));
when.tm_wday = -1;
// parse into the tm_structure
const int a = sscanf(date_time.c_str(), "%d:%d:%d %d:%d:%d",
&when.tm_year, &when.tm_mon, &when.tm_mday,
&when.tm_hour, &when.tm_min, &when.tm_sec);
if (a == 6)
{
when.tm_isdst = -1;
when.tm_mon -= 1; // Adjust for unix zero-based months
when.tm_year -= 1900; // Adjust for year starting at 1900
}
else
{
// Not in EXIF format
return 0;
}
time_t stamp;
stamp = mktime(&when);
if (stamp == (time_t)(-1))
return 0;
return stamp;
}
struct sortbytime
{
sortbytime(map<string, time_t> & h) : m_time(h) {};
bool operator()(const std::string & s1, const std::string & s2)
{
time_t t1 = m_time[s1];
time_t t2 = m_time[s2];
return t1 < t2;
};
map<string, time_t> & m_time;
};
wxString AddImagesSeriesOperation::GetLabel()
{
return _("Add time-series of images...");
};
PT::PanoCommand* AddImagesSeriesOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
//load image if pano contains no images
std::vector<std::string> files;
if(pano.getNrOfImages()==0)
{
if(!AddImageDialog(parent,files))
{
return NULL;
};
//just in case
if(files.size()==0)
{
return NULL;
};
}
else
{
for(size_t i=0;i<pano.getNrOfImages();i++)
{
files.push_back(pano.getImage(i).getFilename());
};
};
DEBUG_TRACE("seeking similarly timed images");
// Collect potential image-mates.
StringToPointerHash filenames;
StringToFlagHash preloaded;
for(size_t i=0;i<files.size();i++)
{
wxString file(files[i].c_str(), HUGIN_CONV_FILENAME);
preloaded[file] = 1;
// Glob for all files of same type in same directory.
wxString path = ::wxPathOnly(file) + wxT("/*");
file = ::wxFindFirstFile(path);
while (!file.IsEmpty())
{
// Associated with a NULL dummy timestamp for now.
if(vigra::isImage(files[i].c_str()))
{
filenames[file] = 0;
};
file = ::wxFindNextFile();
}
}
DEBUG_INFO("found " << filenames.size() << " candidate files to search.");
// For each globbed or loaded file,
StringToPointerHash::iterator found;
std::map<std::string, time_t> timeMap;
for (found = filenames.begin(); found != filenames.end(); found++)
{
wxString file = found->first;
// Check the time if it's got a camera EXIF timestamp.
time_t stamp = ReadExifTime(file.mb_str(HUGIN_CONV_FILENAME));
if (stamp)
{
filenames[file] = stamp;
timeMap[(const char *)file.mb_str(HUGIN_CONV_FILENAME)] = stamp;
}
}
//TODO: sorting the filenames keys by timestamp would be useful
int maxtimediff = wxConfigBase::Get()->Read(wxT("CaptureTimeSpan"), HUGIN_CAPTURE_TIMESPAN);
// For each timestamped file,
for (found = filenames.begin(); found != filenames.end(); found++)
{
wxString recruit = found->first;
if (preloaded[recruit] == 1)
continue;
time_t pledge = filenames[recruit];
if (!pledge)
continue;
// For each other image already loaded,
for(size_t i=0;i<files.size();i++)
{
wxString file(files[i].c_str(), HUGIN_CONV_FILENAME);
if (file == recruit)
continue;
// If it is within threshold time,
time_t stamp = filenames[file];
if (abs((int)(pledge - stamp)) < maxtimediff)
{
// Load this file, and remember it.
DEBUG_TRACE("Recruited " << recruit.mb_str(wxConvLocal));
std::string file = (const char *)recruit.mb_str(HUGIN_CONV_FILENAME);
files.push_back(file);
// Don't recruit it again.
filenames[recruit] = 0;
break;
}
}
}
if(files.size()>0)
{
// sort files by date
sortbytime spred(timeMap);
sort(files.begin(), files.end(), spred);
// Load all of the named files.
return new PT::wxAddImagesCmd(pano,files);
}
else
{
wxMessageBox(
_("No matching images found."),
#ifdef _WINDOWS
_("Hugin"),
#else
wxT(""),
#endif
wxOK | wxICON_INFORMATION, parent);
return NULL;
};
};
wxString RemoveImageOperation::GetLabel()
{
return _("Remove selected image(s)");
};
PT::PanoCommand* RemoveImageOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
//remove images from cache
for (UIntSet::iterator it = images.begin(); it != images.end(); ++it)
{
ImageCache::getInstance().removeImage(pano.getImage(*it).getFilename());
}
return new PT::RemoveImagesCmd(pano, images);
};
wxString ChangeAnchorImageOperation::GetLabel()
{
return _("Anchor this image for position");
};
PT::PanoCommand* ChangeAnchorImageOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
PanoramaOptions opt = pano.getOptions();
opt.optimizeReferenceImage = *(images.begin());
return new PT::SetPanoOptionsCmd(pano,opt);
};
wxString ChangeColorAnchorImageOperation::GetLabel()
{
return _("Anchor this image for exposure");
};
PT::PanoCommand* ChangeColorAnchorImageOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
PanoramaOptions opt = pano.getOptions();
opt.colorReferenceImage = *(images.begin());
// Set the color correction mode so that the anchor image is persisted
if (opt.colorCorrection == 0)
{
opt.colorCorrection = (PanoramaOptions::ColorCorrection) 1;
}
return new PT::SetPanoOptionsCmd(pano, opt);
};
bool NewLensOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
if(pano.getNrOfImages()==0 || images.size()==0)
{
return false;
}
else
{
HuginBase::StandardImageVariableGroups variable_groups(pano);
return variable_groups.getLenses().getNumberOfParts()<pano.getNrOfImages();
};
};
wxString NewLensOperation::GetLabel()
{
return _("New lens");
};
PT::PanoCommand* NewLensOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
return new PT::NewPartCmd(pano, images, HuginBase::StandardImageVariableGroups::getLensVariables());
};
bool ChangeLensOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
if(pano.getNrOfImages()==0 || images.size()==0)
{
return false;
}
else
{
//project must have more than 1 lens before you can assign an other lens number
HuginBase::StandardImageVariableGroups variableGroups(pano);
return variableGroups.getLenses().getNumberOfParts() > 1;
};
};
wxString ChangeLensOperation::GetLabel()
{
return _("Change lens...");
};
PT::PanoCommand* ChangeLensOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
HuginBase::StandardImageVariableGroups variable_groups(pano);
long nr = wxGetNumberFromUser(
_("Enter new lens number"),
_("Lens number"),
_("Change lens number"), 0, 0,
variable_groups.getLenses().getNumberOfParts()-1
);
if (nr >= 0)
{
// user accepted
return new PT::ChangePartNumberCmd(pano, images, nr, HuginBase::StandardImageVariableGroups::getLensVariables());
}
else
{
return NULL;
};
};
LoadLensOperation::LoadLensOperation(bool fromLensfunDB)
{
m_fromLensfunDB=fromLensfunDB;
};
wxString LoadLensOperation::GetLabel()
{
if(m_fromLensfunDB)
{
return _("Load lens from Lensfun database");
}
else
{
return _("Load lens from ini file");
};
};
PT::PanoCommand* LoadLensOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
HuginBase::StandardImageVariableGroups variable_groups(pano);
if(images.size()==1)
{
if(wxMessageBox(_("You selected only one image.\nShould the loaded parameters be applied to all images with the same lens?"),_("Question"), wxICON_QUESTION | wxYES_NO)==wxYES)
{
unsigned int lensNr = variable_groups.getLenses().getPartNumber(*images.begin());
// get all images with the current lens.
for (size_t i = 0; i < pano.getNrOfImages(); i++)
{
if (variable_groups.getLenses().getPartNumber(i) == lensNr)
{
images.insert(i);
};
};
};
};
vigra::Size2D sizeImg0=pano.getImage(*(images.begin())).getSize();
//check if all images have the same size
bool differentImageSize=false;
for(UIntSet::const_iterator it=images.begin();it!=images.end() && !differentImageSize;it++)
{
differentImageSize=(pano.getImage(*it).getSize()!=sizeImg0);
};
if(differentImageSize)
{
if(wxMessageBox(_("You selected images with different sizes.\nApply lens parameter file can result in unwanted results.\nApply settings anyway?"), _("Error"), wxICON_QUESTION |wxYES_NO)==wxID_NO)
{
return NULL;
};
};
PT::PanoCommand* cmd=NULL;
bool isLoaded=false;
if(m_fromLensfunDB)
{
isLoaded=ApplyLensDBParameters(parent,&pano,images,cmd);
}
else
{
isLoaded=ApplyLensParameters(parent,&pano,images,cmd);
};
if(isLoaded)
{
return cmd;
}
else
{
return NULL;
}
};
SaveLensOperation::SaveLensOperation(int lensInfo)
{
m_lensInfo=lensInfo;
};
wxString SaveLensOperation::GetLabel()
{
switch(m_lensInfo)
{
case 0:
return _("Save lens to ini file");
break;
case 1:
return _("Save lens parameters to lensfun database");
break;
case 2:
return _("Save camera parameters to lensfun database");
break;
}
return wxEmptyString;
};
PT::PanoCommand* SaveLensOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
unsigned int imgNr = *(images.begin());
switch(m_lensInfo)
{
case 1:
SaveLensParameters(parent,pano.getImage(imgNr));
break;
case 2:
SaveCameraCropFactor(parent,pano.getImage(imgNr));
break;
case 0:
default:
SaveLensParametersToIni(parent, &pano, images);
break;
};
return NULL;
};
wxString RemoveControlPointsOperation::GetLabel()
{
return _("Remove control points");
};
bool RemoveControlPointsOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
return pano.getNrOfImages()>0 && pano.getNrOfCtrlPoints()>0;
};
PT::PanoCommand* RemoveControlPointsOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
UIntSet selImages;
if(images.size()==0)
{
fill_set(selImages,0,pano.getNrOfCtrlPoints()-1);
}
else
{
selImages=images;
};
UIntSet cpsToDelete;
const CPVector & cps = pano.getCtrlPoints();
for (CPVector::const_iterator it = cps.begin(); it != cps.end(); ++it)
{
if (set_contains(selImages, (*it).image1Nr) && set_contains(selImages, (*it).image2Nr) )
{
cpsToDelete.insert(it - cps.begin());
}
}
if(cpsToDelete.size()==0)
{
wxMessageBox(_("Selected images have no control points."),
#ifdef __WXMSW__
wxT("Hugin"),
#else
wxT(""),
#endif
wxICON_EXCLAMATION | wxOK);
return NULL;
};
int r =wxMessageBox(wxString::Format(_("Really delete %lu control points?"),
(unsigned long int) cpsToDelete.size()),
_("Delete Control Points"),
wxICON_QUESTION | wxYES_NO);
if (r == wxYES)
{
return new PT::RemoveCtrlPointsCmd(pano, cpsToDelete );
}
else
{
return NULL;
};
};
wxString CleanControlPointsOperation::GetLabel()
{
return _("Clean control points");
};
bool CleanControlPointsOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
return pano.getNrOfCtrlPoints()>2;
};
PT::PanoCommand* CleanControlPointsOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
deregisterPTWXDlgFcn();
// work around a flaw in wxProgresDialog that results in incorrect layout
// by pre-allocting sufficient horizontal space
ProgressReporterDialog progress(2, _("Cleaning Control points"), _("Checking pairwise")+wxString((wxChar)' ',10),parent, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_ELAPSED_TIME);
UIntSet removedCPs=getCPoutsideLimit_pair(pano,2.0);
//create a copy to work with
//we copy remaining control points to new pano object for running second step
HuginBase::Panorama newPano=pano.duplicate();
std::map<size_t,size_t> cpMap;
CPVector allCPs=newPano.getCtrlPoints();
CPVector firstCleanedCP;
size_t j=0;
for(size_t i=0;i<allCPs.size();i++)
{
ControlPoint cp=allCPs[i];
if(cp.mode==ControlPoint::X_Y && !set_contains(removedCPs,i))
{
firstCleanedCP.push_back(cp);
cpMap[j++]=i;
};
};
newPano.setCtrlPoints(firstCleanedCP);
//check for unconnected images
CPGraph graph;
createCPGraph(newPano, graph);
CPComponents comps;
int n=findCPComponents(graph, comps);
progress.increaseProgress(1, std::wstring(wxString(_("Checking whole project")).wc_str(wxConvLocal)));
if (n <= 1)
{
//now run the second step
UIntSet removedCP2=getCPoutsideLimit(newPano,2.0);
if(removedCP2.size()>0)
{
for(UIntSet::const_iterator it=removedCP2.begin();it!=removedCP2.end();it++)
{
removedCPs.insert(cpMap[*it]);
};
};
}
progress.increaseProgress(1, std::wstring(wxString(_("Finished cleaning")).wc_str(wxConvLocal)));
registerPTWXDlgFcn(MainFrame::Get());
if(removedCPs.size()>0)
{
wxMessageBox(wxString::Format(_("Removed %lu control points"), removedCPs.size()), _("Cleaning"),wxOK|wxICON_INFORMATION,parent);
return new PT::RemoveCtrlPointsCmd(pano,removedCPs);
};
return NULL;
};
wxString CelesteOperation::GetLabel()
{
return _("Remove control points on clouds");
};
PT::PanoCommand* CelesteOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
ProgressReporterDialog progress(images.size()+2, _("Running Celeste"), _("Running Celeste"),parent);
MainFrame::Get()->SetStatusText(_("searching for cloud-like control points..."),0);
progress.increaseProgress(1.0, std::wstring(wxString(_("Loading model file")).wc_str(wxConvLocal)));
struct celeste::svm_model* model=MainFrame::Get()->GetSVMModel();
if(model==NULL)
{
MainFrame::Get()->SetStatusText(wxT(""),0);
return NULL;
};
// Get Celeste parameters
wxConfigBase *cfg = wxConfigBase::Get();
// SVM threshold
double threshold = HUGIN_CELESTE_THRESHOLD;
cfg->Read(wxT("/Celeste/Threshold"), &threshold, HUGIN_CELESTE_THRESHOLD);
// Mask resolution - 1 sets it to fine
bool t = (cfg->Read(wxT("/Celeste/Filter"), HUGIN_CELESTE_FILTER) == 0);
int radius=(t)?10:20;
DEBUG_TRACE("Running Celeste");
UIntSet cpsToRemove;
for (UIntSet::const_iterator it=images.begin(); it!=images.end(); it++)
{
// Image to analyse
HuginBase::CPointVector cps=pano.getCtrlPointsVectorForImage(*it);
if(cps.size()==0)
{
progress.increaseProgress(1.0, std::wstring(wxString(_("Running Celeste")).wc_str(wxConvLocal)));
continue;
};
ImageCache::EntryPtr img=ImageCache::getInstance().getImage(pano.getImage(*it).getFilename());
vigra::UInt16RGBImage in;
if(img->image16->width()>0)
{
in.resize(img->image16->size());
vigra::copyImage(srcImageRange(*(img->image16)),destImage(in));
}
else
{
ImageCache::ImageCacheRGB8Ptr im8=img->get8BitImage();
in.resize(im8->size());
vigra::transformImage(srcImageRange(*im8),destImage(in),vigra::functor::Arg1()*vigra::functor::Param(65535/255));
};
UIntSet cloudCP=celeste::getCelesteControlPoints(model,in,cps,radius,threshold,800);
in.resize(0,0);
if(cloudCP.size()>0)
{
for(UIntSet::const_iterator it2=cloudCP.begin();it2!=cloudCP.end();it2++)
{
cpsToRemove.insert(*it2);
};
};
progress.increaseProgress(1.0, std::wstring(wxString(_("Running Celeste")).wc_str(wxConvLocal)));
};
progress.increaseProgress(1.0, std::wstring(wxString(_("Running Celeste")).wc_str(wxConvLocal)));
if(cpsToRemove.size()>0)
{
wxMessageBox(wxString::Format(_("Removed %lu control points"), (unsigned long int) cpsToRemove.size()), _("Celeste result"),wxOK|wxICON_INFORMATION);
MainFrame::Get()->SetStatusText(wxT(""),0);
return new PT::RemoveCtrlPointsCmd(pano,cpsToRemove);
}
else
{
MainFrame::Get()->SetStatusText(wxT(""),0);
return NULL;
};
};
ResetOperation::ResetOperation(ResetMode newResetMode)
{
m_resetMode=newResetMode;
m_resetPos=(m_resetMode==RESET_POSITION);
m_resetTranslation=(m_resetMode==RESET_TRANSLATION);
m_resetHFOV=(m_resetMode==RESET_LENS);
m_resetLens=(m_resetMode==RESET_LENS);
m_resetExposure=0;
if(m_resetMode==RESET_PHOTOMETRICS)
{
m_resetExposure=1;
};
m_resetVignetting=(m_resetMode==RESET_PHOTOMETRICS);
if(m_resetMode==RESET_PHOTOMETRICS)
{
m_resetColor=1;
};
m_resetCameraResponse=(m_resetMode==RESET_PHOTOMETRICS);
};
wxString ResetOperation::GetLabel()
{
switch(m_resetMode)
{
case RESET_DIALOG:
case RESET_DIALOG_LENS:
case RESET_DIALOG_PHOTOMETRICS:
return _("Reset user defined...");
break;
case RESET_POSITION:
return _("Reset positions");
break;
case RESET_TRANSLATION:
return _("Reset translation parameters");
break;
case RESET_LENS:
return _("Reset lens parameters");
break;
case RESET_PHOTOMETRICS:
return _("Reset photometric parameters");
};
return wxEmptyString;
};
bool ResetOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
switch(m_resetMode)
{
case RESET_TRANSLATION:
return guiLevel>=GUI_EXPERT && pano.getNrOfImages()>0;
break;
default:
return pano.getNrOfImages()>0;
};
};
PT::PanoCommand* ResetOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
if(m_resetMode==RESET_DIALOG || m_resetMode==RESET_DIALOG_LENS || m_resetMode==RESET_DIALOG_PHOTOMETRICS)
{
if(!ShowDialog(parent))
{
return NULL;
};
};
if(images.size()==0)
{
fill_set(images,0,pano.getNrOfImages()-1);
};
// If we should unlink exposure value (to load it from EXIF)
bool needs_unlink_exposure = false;
bool needs_unlink_redbal = false;
bool needs_unlink_bluebal = false;
double redBalanceAnchor = pano.getImage(pano.getOptions().colorReferenceImage).getExifRedBalance();
double blueBalanceAnchor = pano.getImage(pano.getOptions().colorReferenceImage).getExifBlueBalance();
if(fabs(redBalanceAnchor)<1e-2)
{
redBalanceAnchor=1;
};
if(fabs(blueBalanceAnchor)<1e-2)
{
blueBalanceAnchor=1;
};
VariableMapVector vars;
for(UIntSet::const_iterator it = images.begin(); it != images.end(); it++)
{
unsigned int imgNr = *it;
VariableMap ImgVars=pano.getImageVariables(imgNr);
if(m_resetPos)
{
map_get(ImgVars,"y").setValue(0);
map_get(ImgVars,"p").setValue(0);
map_get(ImgVars,"r").setValue(pano.getSrcImage(imgNr).getExifOrientation());
map_get(ImgVars,"TrX").setValue(0);
map_get(ImgVars,"TrY").setValue(0);
map_get(ImgVars,"TrZ").setValue(0);
map_get(ImgVars,"Tpy").setValue(0);
map_get(ImgVars,"Tpp").setValue(0);
};
if(m_resetTranslation)
{
map_get(ImgVars,"TrX").setValue(0);
map_get(ImgVars,"TrY").setValue(0);
map_get(ImgVars,"TrZ").setValue(0);
map_get(ImgVars,"Tpy").setValue(0);
map_get(ImgVars,"Tpp").setValue(0);
};
SrcPanoImage srcImg = pano.getSrcImage(imgNr);
if(m_resetHFOV)
{
double focalLength=srcImg.getExifFocalLength();
double cropFactor=srcImg.getExifCropFactor();
if(focalLength!=0 && cropFactor!=0)
{
double newHFOV=HuginBase::SrcPanoImage::calcHFOV(srcImg.getProjection(), focalLength, cropFactor, srcImg.getSize());
if(newHFOV!=0)
{
map_get(ImgVars,"v").setValue(newHFOV);
};
};
};
if(m_resetLens)
{
map_get(ImgVars,"a").setValue(0);
map_get(ImgVars,"b").setValue(0);
map_get(ImgVars,"c").setValue(0);
map_get(ImgVars,"d").setValue(0);
map_get(ImgVars,"e").setValue(0);
map_get(ImgVars,"g").setValue(0);
map_get(ImgVars,"t").setValue(0);
};
if(m_resetExposure>0)
{
if(m_resetExposure==1)
{
if (pano.getImage(imgNr).ExposureValueisLinked())
{
/* Unlink exposure value variable so the EXIF values can be
* independant. */
needs_unlink_exposure = true;
}
//reset to exif value
double eV=srcImg.calcExifExposureValue();
if(eV!=0)
{
map_get(ImgVars,"Eev").setValue(eV);
}
}
else
{
//reset to zero
map_get(ImgVars,"Eev").setValue(0);
};
};
if(m_resetColor>0)
{
if(m_resetColor==1)
{
if (pano.getImage(imgNr).WhiteBalanceRedisLinked())
{
/* Unlink red balance variable so the EXIF values can be
* independant. */
needs_unlink_redbal = true;
}
if (pano.getImage(imgNr).WhiteBalanceBlueisLinked())
{
/* Unlink red balance variable so the EXIF values can be
* independant. */
needs_unlink_bluebal = true;
}
double redBal=1;
double blueBal=1;
const SrcPanoImage& img=pano.getImage(imgNr);
const SrcPanoImage& anchor=pano.getImage(pano.getOptions().colorReferenceImage);
// use EXIF Red/BlueBalance data only if image and anchor image are from the same camera
if(img.getExifMake() == anchor.getExifMake() &&
img.getExifModel() == anchor.getExifModel())
{
redBal=fabs(img.getExifRedBalance()/redBalanceAnchor);
if(redBal<1e-2)
{
redBal=1;
};
blueBal=fabs(img.getExifBlueBalance()/blueBalanceAnchor);
if(blueBal<1e-2)
{
blueBal=1;
};
};
map_get(ImgVars,"Er").setValue(redBal);
map_get(ImgVars,"Eb").setValue(blueBal);
}
else
{
map_get(ImgVars,"Er").setValue(1);
map_get(ImgVars,"Eb").setValue(1);
};
};
if(m_resetVignetting)
{
map_get(ImgVars,"Vb").setValue(0);
map_get(ImgVars,"Vc").setValue(0);
map_get(ImgVars,"Vd").setValue(0);
map_get(ImgVars,"Vx").setValue(0);
map_get(ImgVars,"Vy").setValue(0);
};
if(m_resetCameraResponse)
{
map_get(ImgVars,"Ra").setValue(0);
map_get(ImgVars,"Rb").setValue(0);
map_get(ImgVars,"Rc").setValue(0);
map_get(ImgVars,"Rd").setValue(0);
map_get(ImgVars,"Re").setValue(0);
};
vars.push_back(ImgVars);
};
std::vector<PT::PanoCommand *> reset_commands;
if (needs_unlink_exposure)
{
std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables;
variables.insert(HuginBase::ImageVariableGroup::IVE_ExposureValue);
reset_commands.push_back(
new ChangePartImagesLinkingCmd(
pano,
images,
variables,
false,
HuginBase::StandardImageVariableGroups::getLensVariables())
);
}
if (needs_unlink_redbal)
{
std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables;
variables.insert(HuginBase::ImageVariableGroup::IVE_WhiteBalanceRed);
reset_commands.push_back(
new ChangePartImagesLinkingCmd(
pano,
images,
variables,
false,
HuginBase::StandardImageVariableGroups::getLensVariables())
);
}
if (needs_unlink_bluebal)
{
std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> variables;
variables.insert(HuginBase::ImageVariableGroup::IVE_WhiteBalanceBlue);
reset_commands.push_back(
new ChangePartImagesLinkingCmd(
pano,
images,
variables,
false,
HuginBase::StandardImageVariableGroups::getLensVariables())
);
}
reset_commands.push_back(
new PT::UpdateImagesVariablesCmd(pano, images, vars)
);
if(m_resetExposure>0)
{
//reset panorama output exposure value
reset_commands.push_back(new PT::ResetToMeanExposure(pano));
};
return new PT::CombinedPanoCommand(pano, reset_commands);
};
bool ResetOperation::ShowDialog(wxWindow* parent)
{
ResetDialog reset_dlg(parent, m_guiLevel);
bool checkGeometric;
bool checkPhotometric;
switch(m_resetMode)
{
case RESET_DIALOG:
checkGeometric=true;
checkPhotometric=true;
break;
case RESET_DIALOG_LENS:
reset_dlg.LimitToGeometric();
checkGeometric=true;
checkPhotometric=false;
break;
case RESET_DIALOG_PHOTOMETRICS:
reset_dlg.LimitToPhotometric();
checkGeometric=false;
checkPhotometric=true;
};
if(reset_dlg.ShowModal()==wxID_OK)
{
if(checkGeometric)
{
m_resetPos=reset_dlg.GetResetPos();
m_resetTranslation=reset_dlg.GetResetTranslation();
m_resetHFOV=reset_dlg.GetResetFOV();
m_resetLens=reset_dlg.GetResetLens();
};
if(checkPhotometric)
{
if(reset_dlg.GetResetExposure())
{
if(reset_dlg.GetResetExposureToExif())
{
m_resetExposure=1;
}
else
{
m_resetExposure=2;
};
}
else
{
m_resetExposure=0;
};
m_resetVignetting=reset_dlg.GetResetVignetting();
if(reset_dlg.GetResetColor())
{
if(reset_dlg.GetResetColorToExif())
{
m_resetColor=1;
}
else
{
m_resetColor=2;
};
}
else
{
m_resetColor=0;
};
m_resetCameraResponse=reset_dlg.GetResetResponse();
};
return true;
}
else
{
return false;
};
};
bool NewStackOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
if(pano.getNrOfImages()==0 || images.size()==0)
{
return false;
}
else
{
HuginBase::StandardImageVariableGroups variable_groups(pano);
return variable_groups.getStacks().getNumberOfParts()<pano.getNrOfImages();
};
};
wxString NewStackOperation::GetLabel()
{
return _("New stack");
};
PT::PanoCommand* NewStackOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
return new PT::NewPartCmd(pano, images, HuginBase::StandardImageVariableGroups::getStackVariables());
};
bool ChangeStackOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
if(pano.getNrOfImages()==0 || images.size()==0)
{
return false;
}
else
{
//project must have more than 1 stack before you can assign an other stack number
HuginBase::StandardImageVariableGroups variableGroups(pano);
return variableGroups.getStacks().getNumberOfParts() > 1;
};
};
wxString ChangeStackOperation::GetLabel()
{
return _("Change stack...");
};
PT::PanoCommand* ChangeStackOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
HuginBase::StandardImageVariableGroups variable_groups(pano);
long nr = wxGetNumberFromUser(
_("Enter new stack number"),
_("stack number"),
_("Change stack number"), 0, 0,
variable_groups.getStacks().getNumberOfParts()-1
);
if (nr >= 0)
{
// user accepted
return new PT::ChangePartNumberCmd(pano, images, nr, HuginBase::StandardImageVariableGroups::getStackVariables());
}
else
{
return NULL;
};
};
bool AssignStacksOperation::IsEnabled(PT::Panorama& pano, HuginBase::UIntSet images, GuiLevel guiLevel)
{
return pano.getNrOfImages()>1;
};
wxString AssignStacksOperation::GetLabel()
{
return _("Set stack size...");
};
PT::PanoCommand* AssignStacksOperation::GetInternalCommand(wxWindow* parent, PT::Panorama& pano, HuginBase::UIntSet images)
{
long stackSize = wxGetNumberFromUser(
_("Enter image count per stack"),
_("stack size"),
_("Images per stack"), 3, 1,
pano.getNrOfImages()
);
if(stackSize<0)
{
return NULL;
};
std::vector<PT::PanoCommand *> commands;
HuginBase::StandardImageVariableGroups variable_groups(pano);
if(variable_groups.getStacks().getNumberOfParts()<pano.getNrOfImages())
{
// first remove all existing stacks
for(size_t i=1; i<pano.getNrOfImages(); i++)
{
UIntSet imgs;
imgs.insert(i);
commands.push_back(new PT::NewPartCmd(pano, imgs, HuginBase::StandardImageVariableGroups::getStackVariables()));
};
};
if (stackSize > 1)
{
size_t stackNr=0;
size_t imgNr=0;
while(imgNr<pano.getNrOfImages())
{
UIntSet imgs;
for(size_t i=0; i<stackSize && imgNr<pano.getNrOfImages(); i++)
{
imgs.insert(imgNr);
imgNr++;
};
commands.push_back(new PT::ChangePartNumberCmd(pano, imgs, stackNr, HuginBase::StandardImageVariableGroups::getStackVariables()));
stackNr++;
};
};
return new PT::CombinedPanoCommand(pano, commands);
};
static PanoOperationVector PanoOpImages;
static PanoOperationVector PanoOpLens;
static PanoOperationVector PanoOpStacks;
static PanoOperationVector PanoOpControlPoints;
static PanoOperationVector PanoOpReset;
PanoOperationVector* GetImagesOperationVector()
{
return &PanoOpImages;
};
PanoOperationVector* GetLensesOperationVector()
{
return &PanoOpLens;
};
PanoOperationVector* GetStacksOperationVector()
{
return &PanoOpStacks;
};
PanoOperationVector* GetControlPointsOperationVector()
{
return &PanoOpControlPoints;
};
PanoOperationVector* GetResetOperationVector()
{
return &PanoOpReset;
};
void GeneratePanoOperationVector()
{
PanoOpImages.push_back(new AddImageOperation());
PanoOpImages.push_back(new AddImagesSeriesOperation());
PanoOpImages.push_back(new RemoveImageOperation());
PanoOpImages.push_back(new ChangeAnchorImageOperation());
PanoOpImages.push_back(new ChangeColorAnchorImageOperation());
PanoOpLens.push_back(new NewLensOperation());
PanoOpLens.push_back(new ChangeLensOperation());
PanoOpLens.push_back(new LoadLensOperation(false));
PanoOpLens.push_back(new LoadLensOperation(true));
PanoOpLens.push_back(new SaveLensOperation(0));
PanoOpLens.push_back(new SaveLensOperation(1));
PanoOpLens.push_back(new SaveLensOperation(2));
PanoOpStacks.push_back(new NewStackOperation());
PanoOpStacks.push_back(new ChangeStackOperation());
PanoOpStacks.push_back(new AssignStacksOperation());
PanoOpControlPoints.push_back(new RemoveControlPointsOperation());
PanoOpControlPoints.push_back(new CelesteOperation());
PanoOpControlPoints.push_back(new CleanControlPointsOperation());
PanoOpReset.push_back(new ResetOperation(ResetOperation::RESET_POSITION));
PanoOpReset.push_back(new ResetOperation(ResetOperation::RESET_TRANSLATION));
PanoOpReset.push_back(new ResetOperation(ResetOperation::RESET_LENS));
PanoOpReset.push_back(new ResetOperation(ResetOperation::RESET_PHOTOMETRICS));
PanoOpReset.push_back(new ResetOperation(ResetOperation::RESET_DIALOG));
};
void _CleanPanoOperationVector(PanoOperationVector& vec)
{
for(size_t i=0; i<vec.size(); i++)
{
delete vec[i];
}
vec.clear();
};
void CleanPanoOperationVector()
{
_CleanPanoOperationVector(PanoOpImages);
_CleanPanoOperationVector(PanoOpLens);
_CleanPanoOperationVector(PanoOpStacks);
_CleanPanoOperationVector(PanoOpControlPoints);
_CleanPanoOperationVector(PanoOpReset);
};
} //namespace