31 #include "hugin_config.h"
43 template <
class iteratorType>
48 for(iteratorType it(src); it != iteratorType(); it++)
53 projectFiles.push_back(*it);
57 catch(fs::filesystem_error& e)
59 std::cout << e.what() << std::endl;
69 iterateFileSystem<fs::recursive_directory_iterator>(src, projectFiles);
73 iterateFileSystem<fs::directory_iterator>(src, projectFiles);
81 const std::string input = filename.string();
90 std::cout <<
"Checking " << filename.string() <<
"..." << std::endl;
100 std::cout <<
" Ignored (File missing or missing metadata)" << std::endl;
110 std::cout <<
" Saved." << std::endl;
115 std::cout <<
" Ignored." << std::endl;
119 std::cout <<
" Ignored (More than one lens)." << std::endl;
125 std::cout << name <<
": tool for lens database maintenance" << std::endl
128 <<
"Usage: hugin_lensdb [--recursive] --populate BASEPATH " << std::endl
129 <<
" Populate database with information from all pto files" << std::endl
130 <<
" in given BASEPATH" << std::endl
131 <<
" With --recursive switch all subfolders will also be" << std::endl
132 <<
" searched." << std::endl
133 <<
" hugin_lensdb --compress" << std::endl
134 <<
" Compresses the database by replacing single values" << std::endl
135 <<
" with averaged values." << std::endl
136 <<
" hugin_lensdb --remove-lens=LENS" << std::endl
137 <<
" Removes given lens from the database." << std::endl
138 <<
" hugin_lensdb --remove-camera=MAKER|MODEL" << std::endl
139 <<
" Removes given camera from the database." << std::endl
140 <<
" hugin_lensdb --export-database=FILENAME" << std::endl
141 <<
" Export data from database to external file." << std::endl
142 <<
" hugin_lensdb --import-from-file=FILENAME" << std::endl
143 <<
" Import data from external file." << std::endl
147 int main(
int argc,
char* argv[])
150 const char* optstring =
"crph";
159 static struct option longOptions[] =
161 {
"compress", no_argument, NULL,
'c' },
162 {
"recursive", no_argument, NULL,
'r' },
163 {
"populate", required_argument, NULL,
'p' },
164 {
"remove-lens", required_argument, NULL, REMOVE_LENS },
165 {
"remove-camera", required_argument, NULL, REMOVE_CAM },
166 {
"export-database", required_argument, NULL, EXPORT_DB },
167 {
"import-from-file", required_argument, NULL, IMPORT_DB },
168 {
"help", no_argument, NULL,
'h' },
172 bool recursive=
false;
173 bool populate =
false;
174 bool compress =
false;
175 std::string basepath;
176 std::string lensToRemove;
177 std::string camToRemove;
178 std::string exportDatabase;
179 std::string importDatabase;
181 while ((c = getopt_long (argc, argv, optstring, longOptions,
nullptr)) != -1)
221 if (!exportDatabase.empty() && !importDatabase.empty())
223 std::cerr <<
hugin_utils::stripPath(argv[0]) <<
": Export and import can not be done at the same time. " << std::endl;
227 if (!populate && !compress && lensToRemove.empty() && camToRemove.empty() && exportDatabase.empty() && importDatabase.empty())
230 std::cout <<
"Nothing to do." << std::endl;
235 fs::path p(basepath);
239 if (fs::is_directory(p))
243 if (projectFiles.empty())
245 std::cerr <<
"ERROR: No project files found in given directory " << p.string() << std::endl;
248 for (pathVec::const_iterator it = projectFiles.begin(); it != projectFiles.end(); ++it)
255 std::cerr <<
"ERROR: " << basepath <<
" is not a directory." << std::endl;
261 std::cerr <<
"ERROR: Path " << basepath <<
" does not exists." << std::endl;
268 std::cout <<
"Compressing database..." << std::endl;
271 std::cout <<
"Successful." << std::endl;
275 std::cout <<
"FAILED." << std::endl;
279 if (!lensToRemove.empty())
281 std::cout <<
"Removing lens \"" << lensToRemove <<
"\"..." << std::endl;
284 std::cout <<
"Successful." << std::endl;
288 std::cout <<
"FAILED." << std::endl;
292 if (!camToRemove.empty())
295 if (input.size() == 2)
297 std::cout <<
"Removing camera \"" << input[1] <<
"\" (Maker: \"" << input[0] <<
"\")..." << std::endl;
300 std::cout <<
"Successful." << std::endl;
304 std::cout <<
"FAILED." << std::endl;
309 std::cout <<
"\"" << camToRemove <<
"\" is not a valid string for the camera." << std::endl
310 <<
" Use syntax MAKER|MODEL (separate camera maker and model by |)" << std::endl;
314 if (!exportDatabase.empty())
316 std::cout <<
"Exporting database to \"" << exportDatabase <<
"\"..." << std::endl;
319 std::cout <<
"Successful." << std::endl;
323 std::cout <<
"FAILED." << std::endl;
327 if (!importDatabase.empty())
329 std::cout <<
"Importing data from \"" << importDatabase <<
"\"..." << std::endl;
332 std::cout <<
"Successful." << std::endl;
336 std::cout <<
"FAILED." << std::endl;
std::string StrTrim(const std::string &str)
remove trailing and leading white spaces and tabs
static LensDB & GetSingleton()
returns the static LensDB instance
SrcPanoImage getSrcImage(unsigned imgNr) const
get a description of a source image
Somewhere to specify what variables belong to what.
bool SaveLensDataFromPano(const HuginBase::Panorama &pano)
routine for automatically saving information from pano into database
bool CheckProjectFile(const fs::path filename)
bool RemoveLens(const std::string &lensname)
remove all database entry which refers to given lens
std::string toupper(const std::string &s)
static void Clean()
cleanup the static LensDB instance, must be called at the end of the program
std::string GetDBFilename() const
returns the filename of the lens database
bool ExportToFile(const std::string &filename)
export database to file
class to access Hugins camera and lens database
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
std::size_t getNrOfImages() const
number of images.
bool ReadPTOFile(const std::string &filename, const std::string &prefix="")
read pto file from the given filename into Panorama object it does some checks on the file and issues...
ImageVariableGroup & getLenses()
Get the ImageVariableGroup representing the group of lens variables.
bool iterateFileSystem(std::string src, pathVec &projectFiles)
bool ImportFromFile(const std::string &filename)
import data from external file
void FindPTOFiles(pathVec &projectFiles, std::string src, bool recursive)
bool readEXIF()
try to fill out information about the image, by examining the exif data
std::string GetHuginVersion()
return a string with version numbers
void setSrcImage(unsigned int nr, const SrcPanoImage &img)
set input image parameters
std::vector< std::string > SplitString(const std::string &s, const std::string &sep)
split string s at given sep, returns vector of strings
bool RemoveCamera(const std::string &maker, const std::string &model)
remove all database entry which refers to given camera
std::size_t getNumberOfParts() const
get the number of parts.
All variables of a source image.
std::vector< fs::path > pathVec
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
int main(int argc, char *argv[])