Hugin trunk 0.1
Loading...
Searching...
No Matches
PanoDetector.h
Go to the documentation of this file.
1// -*- c-basic-offset: 4 ; tab-width: 4 -*-
2/*
3* Copyright (C) 2007-2008 Anael Orlinski
4*
5* This file is part of Panomatic.
6*
7* Panomatic is free software; you can redistribute it and/or modify
8* it under the terms of the GNU General Public License as published by
9* the Free Software Foundation; either version 2 of the License, or
10* (at your option) any later version.
11*
12* Panomatic is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15* GNU General Public License for more details.
16*
17* You should have received a copy of the GNU General Public License
18* along with Panomatic; if not, write to the Free Software
19* <http://www.gnu.org/licenses/>.
20*/
21
22#ifndef __detectpano_panodetector_h
23#define __detectpano_panodetector_h
24
25#include <hugin_config.h>
26
27#include "PanoDetectorDefs.h"
28#include <memory>
29#include <string>
30#include <map>
31#include <localfeatures/Image.h>
33#include "TestCode.h"
34
37
38#include <flann/flann.hpp>
39
40#include <vigra_ext/ROIImage.h>
41
42#include <panodata/Panorama.h>
44#include <celeste/Celeste.h>
45
47{
48public:
49 typedef std::vector<std::string> FileNameList_t;
50 typedef std::vector<std::string>::iterator FileNameListIt_t;
52 typedef std::shared_ptr<KPKDTree> KPKDTreePtr;
53
55
64
67
68 bool checkData();
69 void printDetails();
70 void printFilenames();
71 void printHelp();
72 void run();
73 bool match(std::vector<HuginBase::UIntSet> &checkedPairs);
74 bool matchMultiRow();
84 bool matchPrealigned(HuginBase::Panorama* pano, std::vector<HuginBase::UIntSet> &connectedImages, std::vector<size_t> imgMap, bool exactOverlap=true);
85
86
87 // accessors
88
90 {
91 return _panoramaInfo;
92 }
93
94 inline void setKeyPointsIdx(std::vector<int> keyPointsIdx)
95 {
97 }
98 inline std::vector<int> getKeyPointsIdx() const
99 {
100 return _keyPointsIdx;
101 }
106 inline bool getWriteAllKeyPoints() const
107 {
108 return _writeAllKeyPoints;
109 }
110
111 inline void setVerbose(int level)
112 {
113 _verbose = level;
114 }
115 inline int getVerbose() const
116 {
117 return _verbose;
118 }
119
120 inline void setSieve1Width(int iWidth)
121 {
123 }
124 inline void setSieve1Height(int iHeight)
125 {
127 }
128 inline void setSieve1Size(int iSize)
129 {
131 }
132 inline int getSieve1Width() const
133 {
134 return _sieve1Width;
135 }
136 inline int getSieve1Height() const
137 {
138 return _sieve1Height;
139 }
140 inline int getSieve1Size() const
141 {
142 return _sieve1Size;
143 }
144
146 {
148 }
149 inline void setKDTreeSecondDistance(double iDist)
150 {
152 }
153 inline int getKDTreeSearchSteps() const
154 {
155 return _kdTreeSearchSteps;
156 }
157 inline double getKDTreeSecondDistance() const
158 {
160 }
161
163 {
165 }
167 {
169 }
171 {
173 }
175 {
176 _ransacMode = mode;
177 }
178 inline int getMinimumMatches() const
179 {
180 return _minimumMatches;
181 }
182 inline int getRansacIterations() const
183 {
184 return _ransacIters;
185 }
186 inline int getRansacDistanceThreshold() const
187 {
189 }
194
195 inline void setSieve2Width(int iWidth)
196 {
198 }
199 inline void setSieve2Height(int iHeight)
200 {
202 }
203 inline void setSieve2Size(int iSize)
204 {
206 }
207 inline int getSieve2Width() const
208 {
209 return _sieve2Width;
210 }
211 inline int getSieve2Height() const
212 {
213 return _sieve2Height;
214 }
215 inline int getSieve2Size() const
216 {
217 return _sieve2Size;
218 }
219
220 inline void setLinearMatchLen(int iLen)
221 {
223 }
224 inline int getLinearMatchLen() const
225 {
226 return _linearMatchLen;
227 }
233 {
234 return _matchingStrategy;
235 }
236
237 inline bool getDownscale() const
238 {
239 return _downscale;
240 }
241 inline void setDownscale(bool iDown)
242 {
244 }
245
246 // inline void setNumberOfKeys(int iNumKeys) { _numKeys = iNumKeys; }
247 inline void setOutputFile(const std::string& outputFile)
248 {
250 _outputGiven=true;
251 }
252 inline void setInputFile(const std::string& inputFile)
253 {
255 }
256 inline void setKeyfilesPath(const std::string& keypath)
257 {
259 }
260 inline bool getCached() const
261 {
262 return _cache;
263 }
264 inline void setCached(bool iCached)
265 {
266 _cache = iCached;
267 }
268 inline bool getCleanup() const
269 {
270 return _cleanup;
271 }
272 inline void setCleanup(bool iCleanup)
273 {
275 }
276 inline bool getCeleste() const
277 {
278 return _celeste;
279 };
280 inline void setCeleste(bool iCeleste)
281 {
283 };
284 inline double getCelesteThreshold() const
285 {
286 return _celesteThreshold;
287 };
292 inline int getCelesteRadius() const
293 {
294 return _celesteRadius;
295 };
297 {
299 };
300 inline void setTest(bool iTest)
301 {
302 _test = iTest;
303 }
304 inline bool getTest() const
305 {
306 return _test;
307 }
308 inline void setCores(int iCores)
309 {
310 _cores = iCores;
311 }
312
313 // predeclaration
314 struct ImgData;
315 struct MatchData;
316
317private:
318 // prevent copying of class
321
322 // options
323
325 std::vector<int> _keyPointsIdx;
326
328
332
335
340
344
347
348 bool _test;
351 bool _cache;
356 std::string _keypath;
357 std::string _prefix;
358
359 // bool _stereoRemap;
360
361 // list of files
362 std::string _outputFile;
364 std::string _inputFile;
365
366 // Store panorama information
369 std::set<std::string> _cpsHashSet;
370
373
377 std::vector<HuginBase::UIntVector> _image_stacks;
378
379 bool loadProject();
380 bool checkLoadSuccess();
381 void CleanupKeyfiles();
382
383 void writeOutput();
385
386 // internals
387public:
388 struct ImgData
389 {
392 std::string _name;
393
397
399 vigra::BImage _distancemap;
400
402
404 std::string _keyfilename;
405
409
410 // kdtree
411 flann::Matrix<double> _flann_descriptors;
412 flann::Index<flann::L2<double> > * _flann_index;
413
415 {
416 _loadFail = false;
417 _number = 0;
418 _detectWidth = 0;
419 _detectHeight = 0;
421 _hasakeyfile = false;
422 _descLength = 0;
424 }
425
427 {
428 if (_flann_index != NULL)
429 {
430 delete _flann_index;
431 };
432 if (_flann_descriptors.rows + _flann_descriptors.cols > 0)
433 {
434 delete[]_flann_descriptors.ptr();
435 };
436 }
438 SizeMode GetSizeMode() const { return m_sizeMode; };
439 bool IsDownscale() const { return m_sizeMode == DOWNSCALED; };
440 bool NeedsRemapping() const { return m_sizeMode == REMAPPED; };
441 private:
443 };
444
445 typedef std::map<int, ImgData> ImgData_t;
446 typedef std::map<int, ImgData>::iterator ImgDataIt_t;
447
454
455 typedef std::vector<MatchData> MatchData_t;
456 typedef std::vector<MatchData>::iterator MatchDataIt_t;
457
458 // actions
460
468
474
475private:
476 bool LoadSVMModel();
479};
480
482std::string getKeyfilenameFor(std::string keyfilesPath, std::string filename);
483
484// dummy panotools progress functions
485static int ptProgress( int command, char* argument )
486{
487 return 1;
488}
489static int ptinfoDlg( int command, char* argument )
490{
491 return 1;
492}
493
494#endif // __detectpano_panodetector_h
!! from PTOptimise.h 1951
static int ptProgress(int command, char *argument)
static int ptinfoDlg(int command, char *argument)
std::string getKeyfilenameFor(std::string keyfilesPath, std::string filename)
returns the filename for the keyfile for a given image
Panorama image options.
Model for a panorama.
Definition Panorama.h:153
ImgData_t _filesData
std::string _keypath
void setSieve1Height(int iHeight)
double _kdTreeSecondDistance
double getKDTreeSecondDistance() const
bool getCleanup() const
static bool AnalyzeImage(ImgData &ioImgInfo, const PanoDetector &iPanoDetector)
static bool MakeKeyPointDescriptorsInImage(ImgData &ioImgInfo, const PanoDetector &iPanoDetector)
void writeKeyfile(ImgData &imgInfo)
int _ransacDistanceThres
void setVerbose(int level)
int getVerbose() const
void setRansacIterations(int iIters)
void setSieve2Width(int iWidth)
std::string _prefix
int getSieve2Width() const
bool getCeleste() const
static bool FindMatchesInPair(MatchData &ioMatchData, const PanoDetector &iPanoDetector)
int getSieve1Size() const
std::string _outputFile
std::vector< std::string > FileNameList_t
void setCleanup(bool iCleanup)
void printHelp()
void CleanupKeyfiles()
double _celesteThreshold
static bool FindKeyPointsInImage(ImgData &ioImgInfo, const PanoDetector &iPanoDetector)
void buildMultiRowImageSets()
search for image layer and image stacks for the multirow matching step
void setSieve1Size(int iSize)
void setRansacMode(HuginBase::RANSACOptimizer::Mode mode)
std::vector< MatchData >::iterator MatchDataIt_t
MatchingStrategy getMatchingStrategy() const
struct celeste::svm_model * svmModel
HuginBase::Panorama * _panoramaInfo
bool getWriteAllKeyPoints() const
int getSieve1Width() const
static bool FilterKeyPointsInImage(ImgData &ioImgInfo, const PanoDetector &iPanoDetector)
std::vector< HuginBase::UIntVector > _image_stacks
vector with image numbers of all stacks, contains only the unlinked stacks
MatchingStrategy
for selecting matching strategy
bool getTest() const
double getCelesteThreshold() const
std::vector< int > _keyPointsIdx
std::map< int, ImgData >::iterator ImgDataIt_t
std::string _inputFile
void setOutputFile(const std::string &outputFile)
void setKDTreeSecondDistance(double iDist)
int getSieve2Height() const
void setSieve2Height(int iHeight)
std::vector< int > getKeyPointsIdx() const
std::vector< std::string >::iterator FileNameListIt_t
void setSieve1Width(int iWidth)
bool match(std::vector< HuginBase::UIntSet > &checkedPairs)
static bool BuildKDTreesInImage(ImgData &ioImgInfo, const PanoDetector &iPanoDetector)
void setKeyPointsIdx(std::vector< int > keyPointsIdx)
void setMatchingStrategy(MatchingStrategy iMatchStrategy)
void setCached(bool iCached)
int getSieve1Height() const
void setRansacDistanceThreshold(int iDT)
void setKeyfilesPath(const std::string &keypath)
int getKDTreeSearchSteps() const
void setInputFile(const std::string &inputFile)
bool matchPrealigned(HuginBase::Panorama *pano, std::vector< HuginBase::UIntSet > &connectedImages, std::vector< size_t > imgMap, bool exactOverlap=true)
does only matches image pairs which overlaps and don't have control points
HuginBase::Panorama * getPanoramaInfo() const
int getMinimumMatches() const
void setCelesteRadius(int iCelesteRadius)
PanoDetector(const PanoDetector &)
static bool RansacMatchesInPairHomography(MatchData &ioMatchData, const PanoDetector &iPanoDetector)
int getRansacDistanceThreshold() const
bool _writeAllKeyPoints
std::vector< MatchData > MatchData_t
HuginBase::RANSACOptimizer::Mode _ransacMode
int getSieve2Size() const
void setLinearMatchLen(int iLen)
bool getCached() const
static bool FreeMemoryInImage(ImgData &ioImgInfo, const PanoDetector &iPanoDetector)
static bool RansacMatchesInPair(MatchData &ioMatchData, const PanoDetector &iPanoDetector)
int getLinearMatchLen() const
static bool RansacMatchesInPairCam(MatchData &ioMatchData, const PanoDetector &iPanoDetector)
void printFilenames()
void setWriteAllKeyPoints(bool writeAllKeyPoints=true)
HuginBase::Panorama _panoramaInfoCopy
void setCelesteThreshold(double iCelesteThreshold)
void setMinimumMatches(int iMatches)
lfeat::KeyPointDetector KeyPointDetector
static bool LoadKeypoints(ImgData &ioImgInfo, const PanoDetector &iPanoDetector)
void setDownscale(bool iDown)
void setCores(int iCores)
std::shared_ptr< KPKDTree > KPKDTreePtr
HuginBase::UIntSet _image_layer
image set contains only the images with the median exposure of each stack
void setCeleste(bool iCeleste)
bool getDownscale() const
std::set< std::string > _cpsHashSet
MatchingStrategy _matchingStrategy
KDTreeSpace::KDTree< KDElemKeyPoint, double > KPKDTree
static bool RemapBackKeypoints(ImgData &ioImgInfo, const PanoDetector &iPanoDetector)
int getCelesteRadius() const
std::map< int, ImgData > ImgData_t
void setTest(bool iTest)
int getRansacIterations() const
void setSieve2Size(int iSize)
bool checkLoadSuccess()
PanoDetector & operator=(const PanoDetector &)
HuginBase::RANSACOptimizer::Mode getRansacMode()
static bool FilterMatchesInPair(MatchData &ioMatchData, const PanoDetector &iPanoDetector)
void setKDTreeSearchSteps(int iSteps)
std::set< unsigned int > UIntSet
std::vector< PointMatchPtr > PointMatchVector_t
Definition PointMatch.h:53
std::vector< KeyPointPtr > KeyPointVect_t
Definition KeyPoint.h:111
flann::Index< flann::L2< double > > * _flann_index
flann::Matrix< double > _flann_descriptors
bool IsDownscale() const
HuginBase::PanoramaOptions _projOpts
bool NeedsRemapping() const
void SetSizeMode(const SizeMode newSizeMode)
SizeMode GetSizeMode() const
lfeat::KeyPointVect_t _kp
vigra::BImage _distancemap
SizeMode
enumeration of different detection modes
lfeat::PointMatchVector_t _matches
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