Hugin trunk 0.1
Loading...
Searching...
No Matches
Panorama.h
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
24#ifndef _PANODATA_PANORAMA_H
25#define _PANODATA_PANORAMA_H
26
27// if this file is preprocessed for SWIG, we want to ignore
28// all the header inclusions that follow:
29
30#ifndef _HSI_IGNORE_SECTION
31
32#include <hugin_shared.h>
33#include <list>
36
37
38#endif // _HSI_IGNORE_SECTION
39
40namespace HuginBase {
41
50{
51
52 friend class Panorama;
53
54 public:
56 : PanoramaDataMemento(), optSwitch(0), optPhotoSwitch(0), needsOptimization(false)
57 {};
58
61
63 PanoramaMemento& operator=(const PanoramaMemento & o);
64
65 virtual ~PanoramaMemento();
66
71 bool loadPTScript(std::istream & i, int & ptoVersion, const std::string & prefix = "");
72
73 private:
82
90 std::vector<SrcPanoImage *> images;
92 std::string iccProfileDesc;
95 int bands = 0;
96
98
100
106
107 // indicates that changes have been made to
108 // control points or lens parameters after the
109 // last optimisation
111
112 void deleteAllImages();
113};
114
115
116
153{
154
155 public:
156
159 Panorama();
160
163 ~Panorama();
164
165
166 // ====================== PanoramaData =========================================
167
168
174 Panorama getSubset(const UIntSet & imgs) const;
175
180 Panorama duplicate() const;
181
184 {
185 return new Panorama(this->getSubset(imgs));
186 }
187
190 {
191 return new Panorama(this->duplicate());
192 }
193
198 PanoramaData* getUnlinkedSubset(UIntSetVector& imageGroups) const;
199
200 // -- Data Access --
201
202 // = images =
203
205 std::size_t getNrOfImages() const
206 {
207 return state.images.size();
208 };
209
211 inline const SrcPanoImage & getImage(std::size_t nr) const
212 {
213 assert(nr < state.images.size());
214 return *state.images[nr];
215 };
216
218 void setImage(std::size_t nr, const SrcPanoImage & img)
219 {
220 setSrcImage(nr, img);
221 };
222
224 // unsigned int getImageNr(const PanoImage * image) const;
225
228 unsigned int addImage(const SrcPanoImage &img);
229
231 void mergePanorama(const Panorama &newPano);
232
234// int addImageAndLens(const std::string & filename);
235
239 // unsigned int addImage(const std::string & filename);
240
246 void removeImage(unsigned int nr);
247
252 void swapImages(unsigned int img1, unsigned int img2);
253
258 void moveImage(size_t img1, size_t img2);
259
268 SrcPanoImage getSrcImage(unsigned imgNr) const;
269
276 void setSrcImage(unsigned int nr, const SrcPanoImage & img);
277
284 void setImageFilename(unsigned int img, const std::string & fname);
285
297 void activateImage(unsigned int imgNr, bool active=true);
298
300 UIntSet getActiveImages() const;
301
302
303 // = CPs =
304
306 std::size_t getNrOfCtrlPoints() const
307 {
308 return state.ctrlPoints.size();
309 };
310
312 const ControlPoint & getCtrlPoint(std::size_t nr) const
313 {
314 assert(nr < state.ctrlPoints.size());
315 return state.ctrlPoints[nr];
316 };
317
319 const CPVector & getCtrlPoints() const
320 { return state.ctrlPoints; };
321
323 std::vector<unsigned int> getCtrlPointsForImage(unsigned int imgNr) const;
324
327 CPointVector getCtrlPointsVectorForImage(unsigned int imgNr) const;
328
330 void setCtrlPoints(const CPVector & points);
331
333 unsigned int addCtrlPoint(const ControlPoint & point);
334
337 void removeCtrlPoint(unsigned int pNr);
338
341 void removeDuplicateCtrlPoints();
342
345 void changeControlPoint(unsigned int pNr, const ControlPoint & point);
346
348 // unsigned int getCtrlPointNr(const ControlPoint * point) const;
349
351 int getNextCPTypeLineNumber() const;
352
354 void updateLineCtrlPoints();
355
356
363 void updateCtrlPointErrors(const CPVector & controlPoints);
364
371 void updateCtrlPointErrors(const UIntSet & imgs, const CPVector & cps);
372
374 const std::string getICCProfileDesc() const;
376 void setICCProfileDesc(const std::string& newDesc);
379 const int getNrOfBands() const;
381 void setNrOfBands(const int nrBands);
382
383 // = Variables =
384
386 VariableMapVector getVariables() const;
387
395 const VariableMap getImageVariables(unsigned int imgNr) const;
396
402 virtual void updateVariables(const VariableMapVector & vars);
403
405 virtual void updateVariables(const UIntSet & imgs, const VariableMapVector & var);
406
410 virtual void updateVariables(unsigned int imgNr, const VariableMap & var);
411
417 virtual void updateVariable(unsigned int imgNr, const Variable &var);
418
420 virtual void UpdateFocalLength(UIntSet imgs, double newFocalLength);
422 virtual void UpdateCropFactor(UIntSet imgs, double newCropFactor);
423 /* Link image variable functions. Used to group image variables which
424 * should share the same value. The initial value is the one kept by
425 * the image with number sourceImgNr.
426 */
427#define image_variable( name, type, default_value ) \
428 virtual void linkImageVariable##name(unsigned int sourceImgNr, unsigned int destImgNr);
429#include "image_variables.h"
430#undef image_variable
431
432 /* Unlink image variable functions. Makes a image variable independant
433 * of the other images.
434 */
435#define image_variable( name, type, default_value ) \
436 virtual void unlinkImageVariable##name(unsigned int imgNr);
437#include "image_variables.h"
438#undef image_variable
439
443 virtual void updateWhiteBalance(double redFactor, double blueFactor);
444
446 const double getMaxExposureDifference() const;
448 const bool hasPossibleStacks() const;
450 void linkPossibleStacks(bool linkPosition);
451
452 // = Optimise Vector =
455 { return state.optvec; };
456
458 void setOptimizeVector(const OptimizeVector & optvec);
459
461 const int getOptimizerSwitch() const
462 { return state.optSwitch;};
464 void setOptimizerSwitch(const int newSwitch);
465
468 { return state.optPhotoSwitch; };
470 void setPhotometricOptimizerSwitch(const int newSwitch);
471
478 // = Panorama options =
479
482 { return state.options; };
483
488 void setOptions(const PanoramaOptions & opt);
489
490
491
492 // -- script interface --
493
495 void printPanoramaScript(std::ostream & o,
496 const OptimizeVector & optvars,
497 const PanoramaOptions & options,
498 const UIntSet & imgs,
499 bool forPTOptimizer,
500 const std::string & stripPrefix="") const;
501
503 void printStitcherScript(std::ostream & o,
504 const PanoramaOptions & target,
505 const UIntSet & imgs) const;
506
507
508
509 //=========== ManagedPanoramaData ==============================================
510
511
512
513 // -- Observing --
514
521 void addObserver(PanoramaObserver *o);
522
531 bool removeObserver(PanoramaObserver *observer);
532
537 void clearObservers();
538
544 const bool hasPendingChanges() const;
545
555 void changeFinished(bool keepDirty);
556
565 { changeFinished(false); }
566
572 void imageChanged(unsigned int imgNr);
573
575 void updateMasksForImage(unsigned int imgNr, MaskPolygonVector newMasks);
581 void updateMasks(bool convertPosMaskToNeg=false);
584 void transferMask(MaskPolygon mask,unsigned int imgNr, const UIntSet& targetImgs);
586 void updateOptimizeVector();
588 std::set<size_t> getRefImages();
591 void checkRefOptStatus(bool& linkRefImgsYaw, bool& linkRefImgsPitch, bool& linkRefImgsRoll);
592
593 // -- Memento interface --
594
596 virtual PanoramaDataMemento* getNewMemento() const;
597
599 virtual bool setMementoToCopyOf(const PanoramaDataMemento* const memento);
600
603 { return state; }
604
606 void setMemento(const PanoramaMemento& memento);
607
608
609 // -- Optimization Status --
610
615 { return state.needsOptimization; };
616
619 { state.needsOptimization = !optimized; };
620
621
622
623 //=========== Document Data ====================================================
624
625 public:
631 bool ReadPTOFile(const std::string& filename, const std::string& prefix = "");
633 bool WritePTOFile(const std::string& filename, const std::string& prefix = "");
634
636 bool isDirty() const
637 {
638 if (dirty != AppBase::DocumentData::isDirty())
639 DEBUG_WARN("modification status mismatch.");
640
641 return dirty;
642 }
643
645 virtual void clearDirty()
646 {
648 dirty = false;
649 }
650
651 protected:
652 void setDirty(const bool& dirty = true)
653 {
655
656 this->dirty = dirty;
657 }
658
659
660 // == additional methods for documents ==
661
662 public:
664 void setFilePrefix(std::string prefix)
665 { imgFilePrefix = prefix; }
666
667 protected:
668 std::string getFilePrefix() const
669 { return imgFilePrefix; }
670
671 //=========== Internal methods =================================================
672
673 public:
675 void reset();
676
677 protected:
681 private:
683 void centerCrop(unsigned int imgNr);
685 vigra::Rect2D centerCropImage(unsigned int imgNr);
687 void updateCropMode(unsigned int imgNr);
688
689 std::string imgFilePrefix;
690
692 bool dirty;
693
695 std::list<PanoramaObserver *> observers;
698
700
701 std::set<std::string> m_ptoptimizerVarNames;
702};
703
704} // namespace
705#endif // _PANORAMA_H
virtual void clearDirty()
virtual void setDirty(const bool &dirty=true)
virtual bool isDirty() const
represents a control point
base class, which stores one mask polygon
Definition Mask.h:53
Memento class for a PanoramaData object.
Model for a panorama.
Memento class for a Panorama object.
Definition Panorama.h:50
std::vector< SrcPanoImage * > images
The images inside the panorama.
Definition Panorama.h:90
PanoramaOptions options
Definition Panorama.h:99
OptimizeVector optvec
Definition Panorama.h:101
std::string iccProfileDesc
description of the icc profile
Definition Panorama.h:92
int optSwitch
stores the optimizer switch, use OR of HuginBase::OptimizerSwitches
Definition Panorama.h:103
int optPhotoSwitch
stores the photometric optimizer switch, use OR of HuginBase::OptimizerSwitches
Definition Panorama.h:105
this handler class will receive change events from the Panorama.
Panorama image options.
Model for a panorama.
Definition Panorama.h:153
UIntSet changedImages
the images that have been changed since the last changeFinished()
Definition Panorama.h:697
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition Panorama.h:211
const PanoramaOptions & getOptions() const
returns the options for this panorama
Definition Panorama.h:481
PanoramaData * getNewCopy() const
Definition Panorama.h:189
virtual void clearDirty()
clear dirty flag.
Definition Panorama.h:645
bool isDirty() const
true if there are unsaved changes
Definition Panorama.h:636
std::string getFilePrefix() const
Definition Panorama.h:668
std::list< PanoramaObserver * > observers
Definition Panorama.h:695
void setImage(std::size_t nr, const SrcPanoImage &img)
set a panorama image, counting starts with 0
Definition Panorama.h:218
const ControlPoint & getCtrlPoint(std::size_t nr) const
get a control point, counting starts with 0
Definition Panorama.h:312
const int getPhotometricOptimizerSwitch() const
return the photometric optimizer master switch
Definition Panorama.h:467
std::size_t getNrOfCtrlPoints() const
number of control points
Definition Panorama.h:306
std::set< std::string > m_ptoptimizerVarNames
Definition Panorama.h:701
PanoramaMemento state
Definition Panorama.h:694
void markAsOptimized(bool optimized=true)
Definition Panorama.h:618
void changeFinished()
notify observers about changes in this class
Definition Panorama.h:564
const CPVector & getCtrlPoints() const
get all control point of this Panorama
Definition Panorama.h:319
bool dirty
this indicates that there are unsaved changes
Definition Panorama.h:692
PanoramaMemento getMemento() const
get the internal state
Definition Panorama.h:602
const OptimizeVector & getOptimizeVector() const
return the optimize settings stored inside panorama
Definition Panorama.h:454
PanoramaData * getNewSubset(const UIntSet &imgs) const
Definition Panorama.h:183
void setDirty(const bool &dirty=true)
Definition Panorama.h:652
std::string imgFilePrefix
Definition Panorama.h:689
const int getOptimizerSwitch() const
returns optimizer master switch
Definition Panorama.h:461
void adjustVarLinks()
adjust the links of the linked variables, must be called when a lens has been changed.
void setFilePrefix(std::string prefix)
sets the path prefix of the images reffered with relative paths
Definition Panorama.h:664
bool needsOptimization()
true if control points or lens variables have been changed after the last optimisation
Definition Panorama.h:614
std::size_t getNrOfImages() const
number of images.
Definition Panorama.h:205
All variables of a source image.
a variable has a value and a name.
#define IMPEX
#define DEBUG_WARN(msg)
Definition utils.h:74
This file specifies what image variables SrcPanoImg should have.
mainly consists of wrapper around the pano tools library, to assist in ressource management and to pr...
Definition wxcms.cpp:39
std::vector< MaskPolygon > MaskPolygonVector
Definition Mask.h:150
std::vector< VariableMap > VariableMapVector
std::vector< ControlPoint > CPVector
std::vector< std::set< std::string > > OptimizeVector
std::vector< CPoint > CPointVector
std::vector< UIntSet > UIntSetVector
std::set< unsigned int > UIntSet
std::map< std::string, Variable > VariableMap
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41