32#include <vigra/imageinfo.hxx>
41#include <hugin_config.h>
42#include <mach-o/dyld.h>
47static void usage(
const char* name)
49 std::cout << name <<
": generate project file from images" << std::endl
52 <<
"Usage: " << name <<
" [options] image1 [...]" << std::endl
54 <<
" Options:" << std::endl
55 <<
" -o, --output=file.pto Output Hugin PTO file." << std::endl
56 <<
" -p, --projection=INT Projection type (default: read from database)" << std::endl
57 <<
" -f, --fov=FLOAT Horizontal field of view of images" << std::endl
58 <<
" default: read from database" << std::endl
59 <<
" --ignore-fov-rectilinear Don't read fov for rectilinear images from" <<std::endl
60 <<
" the database, instead use only the values" << std::endl
61 <<
" from EXIF data" << std::endl
62 <<
" -c, --crop=left,right,top,bottom Sets the crop of input" << std::endl
63 <<
" images (especially for fisheye lenses)" << std::endl
64 <<
" -s, --stacklength=INT Number of images in stack" << std::endl
65 <<
" (default: automatic detection)" << std::endl
66 <<
" -l, --linkstacks Link image positions in stacks" << std::endl
67 <<
" --distortion Try to load distortion information from" << std::endl
68 <<
" lens database" << std::endl
69 <<
" --vignetting Try to load vignetting information from" << std::endl
70 <<
" lens database" << std::endl
71 <<
" --sort Sort the files by name alphanumeric" << std::endl
72 <<
" otherwise the images are processed in the order" << std::endl
73 <<
" given at the command line" << std::endl
74 <<
" -h, --help Shows this help" << std::endl
114 bool loadDistortion=
false;
156 int left, right, top, bottom;
157 int n=
sscanf(
optarg,
"%d,%d,%d,%d", &left, &right, &top, &bottom);
160 if(right>left && bottom>top)
162 cropRect.setUpperLeft(vigra::Point2D(left,top));
163 cropRect.setLowerRight(vigra::Point2D(right,bottom));
218 std::cout <<
"Generating pto file..." << std::endl;
260 if(vigra::isImage(
input.c_str()))
290 std::cerr <<
"Ignoring raw file " <<
filelist[
i] <<
"." << std::endl;
294 std::cout <<
"Reading " <<
filelist[
i] <<
"..." << std::endl;
299 if(info.width()==0 || info.height()==0)
301 std::cerr <<
"ERROR: Could not decode image " <<
filelist[
i] << std::endl
302 <<
"Skipping this image." << std::endl << std::endl;
305 srcImage.setSize(info.size());
307 const std::string
pixelType=info.getPixelType();
310 std::cerr <<
"ERROR: Image " <<
filelist[
i] <<
" is a black/white images." << std::endl
311 <<
" This is not supported. Convert to grayscale image and try again." << std::endl
312 <<
" Skipping this image." << std::endl;
331 catch(std::exception& e)
333 std::cerr <<
"ERROR: caught exception: " << e.what() << std::endl;
334 std::cerr <<
"Could not read image information for file " <<
filelist[
i] << std::endl;
335 std::cerr <<
"Skipping this image." << std::endl << std::endl;
340 bool fovOk=srcImage.applyEXIFValues();
351 srcImage.setHFOV(fov);
352 if(srcImage.getCropFactor()==0)
354 srcImage.setCropFactor(1.0);
362 std::cout <<
"\tNo value for field of view found in EXIF data. " << std::endl
363 <<
"\tAssuming a HFOV of 50 degrees. " << std::endl;
364 srcImage.setHFOV(50);
365 srcImage.setCropFactor(1.0);
370 if(srcImage.isCircularCrop())
378 srcImage.setAutoCenterCrop(
false);
383 if(srcImage.readDistortionFromDB())
385 std::cout <<
"\tRead distortion data from lens database." << std::endl;
389 std::cout <<
"\tNo valid distortion data found in lens database." << std::endl;
394 if(srcImage.readVignettingFromDB())
396 std::cout <<
"\tRead vignetting data from lens database." << std::endl;
400 std::cout <<
"\tNo valid vignetting data found in lens database." << std::endl;
418 srcImage.setWhiteBalanceRed(srcImage.getExifRedBalance() /
redBalanceAnchor);
426 std::cerr <<
"Adding images to project files failed." << std::endl;
441 for(
size_t j=0;
j<
i;
j++)
459 std::cout << std::endl <<
"Assigned " <<
lenses.getNumberOfParts() <<
" lenses." << std::endl;
462 std::cout <<
"Project contains more than one lens, but you requested to assign" << std::endl
463 <<
"stacks. This is not supported. Therefore stacks will not be" << std::endl
464 <<
"assigned." << std::endl << std::endl;
518 std::cout <<
"Assigned " <<
stackCount <<
" stacks: " << std::endl
519 <<
"\t" << (
linkStacks ?
"Linking position of images in stacks" :
"Use individual positions of images in stacks") << std::endl;
547 std::cout << std::endl <<
"Written output to " <<
output << std::endl;
class to access Hugins camera and lens database
some definitions to work with optimizer master switches
Somewhere to specify what variables belong to what.
@ RESPONSE_LINEAR
linear response
@ RESPONSE_EMOR
empirical model of response
static double calcMeanExposure(const PanoramaData &pano)
Same as above, but use a non const panorama.
static void Clean()
cleanup the static LensDB instance, must be called at the end of the program
double outputExposureValue
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
const PanoramaOptions & getOptions() const
returns the options for this panorama
const bool hasPossibleStacks() const
return true, if the metadata indicates that the projects is a bracketet project
void updateOptimizeVector()
updates the optimize vector according to master switches
unsigned int addImage(const SrcPanoImage &img)
the the number for a specific image
void setOptions(const PanoramaOptions &opt)
set new output settings This is not used directly for optimizing/stiching, but it can be feed into ru...
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
void setPhotometricOptimizerSwitch(const int newSwitch)
sets the photometric optimizer master switch
void linkPossibleStacks(bool linkPosition)
create automatically stacks as indicated by metadata
void setOptimizerSwitch(const int newSwitch)
set optimizer master switch
std::size_t getNrOfImages() const
number of images.
All variables of a source image.
std::string GetAbsoluteFilename(const std::string &filename)
returns the full absolute filename
std::string stripExtension(const std::string &basename2)
remove extension of a filename
bool IsLinearICCProfile(const vigra::ImageImportInfo::ICCProfile &iccProfile)
return true if icc profile is linear one, otherwise return false
std::string getExtension(const std::string &basename2)
Get extension of a filename.
bool IsRawExtension(const std::string testExt)
return true if extension belongs to a raw file
std::string GetHuginVersion()
return a string with version numbers
bool FileExists(const std::string &filename)
checks if file exists
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
int main(int argc, char *argv[])
Functor class to compare two objects with the "Alphanum Algorithm".
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.