46static void usage(
const char* name)
48 std::cout << name <<
": change output parameters of project file" << std::endl
51 <<
"Usage: " << name <<
" [options] input.pto" << std::endl
53 <<
" Options:" << std::endl
54 <<
" -o, --output=file.pto Output Hugin PTO file. Default: <filename>_mod.pto" << std::endl
55 <<
" -p, --projection=x Sets the output projection to number x" << std::endl
56 <<
" --projection-parameter=x Sets the parameter of the projection" << std::endl
57 <<
" (Several parameters are separated by"<<std::endl
58 <<
" space or comma)" << std::endl
59 <<
" --fov=AUTO|HFOV|HFOVxVFOV Sets field of view" << std::endl
60 <<
" AUTO: calculates optimal fov" << std::endl
61 <<
" HFOV|HFOVxVFOV: set to given fov" << std::endl
62 <<
" -s, --straighten Straightens the panorama" << std::endl
63 <<
" -c, --center Centers the panorama" << std::endl
64 <<
" --canvas=AUTO|num%|WIDTHxHEIGHT Sets the output canvas size" << std::endl
65 <<
" AUTO: calculate optimal canvas size" << std::endl
66 <<
" num%: scales the optimal size by given percent" << std::endl
67 <<
" WIDTHxHEIGHT: set to given size" << std::endl
68 <<
" --crop=AUTO|AUTOHDR|AUTOOUTSIDE|left,right,top,bottom|left,right,top,bottom%" << std::endl
69 <<
" Sets the crop rectangle" << std::endl
70 <<
" AUTO: autocrop panorama" << std::endl
71 <<
" AUTOHDR: autocrop HDR panorama" << std::endl
72 <<
" AUTOOUTSIDE: autocrop outside of all images" << std::endl
73 <<
" left,right,top,bottom: to given size" << std::endl
74 <<
" left,right,top,bottom%: to size relative to canvas" << std::endl
75 <<
" --output-exposure=AUTO|num Sets the output exposure value to mean" << std::endl
76 <<
" exposure (AUTO) or to given value" << std::endl
77 <<
" Prefix number with r for relativ change" << std::endl
78 <<
" --output-range-compression=num Set range compression" << std::endl
79 <<
" Value should be a real in range 0..20" << std::endl
80 <<
" --output-cropped-tiff Output cropped tiffs as intermediate images" << std::endl
81 <<
" --output-uncropped-tiff Output uncropped tiffs as intermediate images" << std::endl
82 <<
" --output-type=str Sets the type of output" << std::endl
83 <<
" Valid items are" << std::endl
84 <<
" NORMAL|N: normal panorama" << std::endl
85 <<
" STACKSFUSEDBLENDED|BF: LDR panorama with" << std::endl
86 <<
" blended stacks" << std::endl
87 <<
" EXPOSURELAYERSFUSED|FB: LDR panorama with" << std::endl
88 <<
" fused exposure layers (any arrangement)" << std::endl
89 <<
" HDR: HDR panorama" << std::endl
90 <<
" REMAP: remapped images with corrected exposure" << std::endl
91 <<
" REMAPORIG: remapped images with" << std::endl
92 <<
" uncorrected exposure" << std::endl
93 <<
" HDRREMAP: remapped images in linear color space" << std::endl
94 <<
" FUSEDSTACKS: exposure fused stacks" << std::endl
95 <<
" HDRSTACKS: HDR stacks" << std::endl
96 <<
" EXPOSURELAYERS: blended exposure layers" << std::endl
97 <<
" and separated by a comma." << std::endl
98 <<
" --ldr-file=JPG|TIF|PNG Sets the filetype for LDR panorama output" << std::endl
99 <<
" --ldr-compression=str Sets the compression for LDR panorama output" << std::endl
100 <<
" For TIF: NONE|PACKBITS|LZW|DEFLATE" << std::endl
101 <<
" For JPEG: quality as number" << std::endl
102 <<
" --hdr-file=EXR|TIF Sets the filetype for HDR panorama output" << std::endl
103 <<
" --hdr-compression=str Sets the compression for HDR panorama output" << std::endl
104 <<
" For TIF: NONE|PACKBITS|LZW|DEFLATE" << std::endl
105 <<
" --blender=ENBLEND|INTERNAL Sets the blender to be used at stitching" << std::endl
106 <<
" stage." << std::endl
107 <<
" --blender-args=str Sets the arguments for the blender" << std::endl
108 <<
" --fusion-args=str Sets the arguments for the fusion program" << std::endl
109 <<
" --hdrmerge-args=str Setst the arguments for hdrmerge" << std::endl
110 <<
" --rotate=yaw,pitch,roll Rotates the whole panorama with the given angles" << std::endl
111 <<
" --translate=x,y,z Translate the whole panorama with the given values" << std::endl
112 <<
" --interpolation=int Sets the interpolation method" << std::endl
113 <<
" --ini=FILE Read the settings from the given FILE and apply it" << std::endl
114 <<
" --template=TEMPLATE Read the panorama options from the given TEMPLATE" << std::endl
115 <<
" and apply it" << std::endl
116 <<
" -h, --help Shows this help" << std::endl
190 vigra::Rect2D
newROI(0,0,0,0);
208 double outputRangeCompression = -1;
210 bool calcMeanExposure =
false;
219#define EMPTYARG "(empty)"
246 std::cerr <<
hugin_utils::stripPath(
argv[0]) <<
": projection " << projection <<
" is an invalid projection number." << std::endl;
333 int pos=param.find(
"%");
334 if(
pos!=std::string::npos)
336 param=param.substr(0,
pos);
337 scale=
atoi(param.c_str());
351 if(width>0 && height>0)
380 if (param ==
"AUTOHDR")
386 if (param ==
"AUTOOUTSIDE")
392 const int pos = param.find(
"%");
393 if (
pos != std::string::npos)
396 param = param.substr(0,
pos);
397 double left, right, top, bottom;
398 const int n =
sscanf(param.c_str(),
"%lf,%lf,%lf,%lf", &left, &right, &top, &bottom);
401 if (right > left && bottom > top && left >= 0.0 && top >= 0.0 && right <= 100.0 && bottom <= 100.0)
421 int left, right, top, bottom;
422 int n =
sscanf(
optarg,
"%d,%d,%d,%d", &left, &right, &top, &bottom);
425 if (right > left && bottom > top && left >= 0 && top >= 0)
427 newROI.setUpperLeft(vigra::Point2D(left, top));
428 newROI.setLowerRight(vigra::Point2D(right, bottom));
457 calcMeanExposure =
true;
626 std::cout <<
"Setting projection to " << proj.name << std::endl;
636 std::cout <<
"Warning: Given " <<
projParameter.size() <<
" projection parameters, but projection supports" << std::endl
637 <<
" only " <<
opt.
m_projFeatures.numberOfParameters <<
". Ignoring surplus parameters." << std::endl;
651 std::cout <<
"Setting projection parameters to: " << *
it;
655 std::cout <<
", " << *
it;
658 std::cout << std::endl;
663 std::cout <<
"Warning: Current projection does not support projection parameters." << std::endl;
670 if (calcMeanExposure)
685 std::cout <<
"Setting output exposure value to " <<
opt.outputExposureValue << std::endl;
689 if (outputRangeCompression >= 0.0)
693 std::cout <<
"Setting output range compression to " <<
opt.outputRangeCompression << std::endl;
703 opt.outputLDRExposureBlended =
false;
704 opt.outputLDRExposureLayersFused =
false;
705 opt.outputHDRBlended =
false;
707 opt.outputLDRLayers =
false;
708 opt.outputLDRExposureRemapped =
false;
709 opt.outputHDRLayers =
false;
711 opt.outputLDRStacks =
false;
712 opt.outputHDRStacks =
false;
714 opt.outputLDRExposureLayers =
false;
718 for (
size_t i = 0;
i <
tokens.size();
i++)
721 if (
s ==
"NORMAL" ||
s==
"N")
723 opt.outputLDRBlended =
true;
724 std::cout <<
"Activate output of normal panorama." << std::endl;
728 if (
s ==
"STACKSFUSEDBLENDED" ||
s ==
"FB")
730 opt.outputLDRExposureBlended =
true;
731 std::cout <<
"Activate output of LDR panorama: Exposure fused from stacks." << std::endl;
735 if (
s ==
"EXPOSURELAYERSFUSED" ||
s ==
"BF")
737 opt.outputLDRExposureLayersFused =
true;
738 std::cout <<
"Activate output of LDR panorama: Exposure fused from any arrangement." << std::endl;
744 opt.outputHDRBlended =
true;
745 std::cout <<
"Activate output of hdr panorama." << std::endl;
752 opt.outputLDRLayers =
true;
753 std::cout <<
"Activate output of remapped, exposure corrected images." << std::endl;
757 if (
s ==
"REMAPORIG")
759 opt.outputLDRExposureRemapped =
true;
760 std::cout <<
"Activate output of remapped images with unmodified exposure." << std::endl;
766 opt.outputHDRLayers =
true;
767 std::cout <<
"Activate output of remapped hdr images." << std::endl;
772 if (
s ==
"FUSEDSTACKS")
774 opt.outputLDRStacks =
true;
775 std::cout <<
"Activate output of exposure fused stacks." << std::endl;
779 if (
s ==
"HDRSTACKS")
781 opt.outputHDRStacks =
true;
782 std::cout <<
"Activate output of HDR stacks." << std::endl;
787 if (
s ==
"EXPOSURELAYERS")
789 opt.outputLDRExposureLayers =
true;
790 std::cout <<
"Activate output of exposure layers." << std::endl;
794 std::cout <<
"Unknown parameter \"" <<
s <<
"\" found in --output-type." << std::endl
795 <<
"Ignoring this parameter." << std::endl;
803 std::cout <<
"No matching output type given. The whole output-type is ignored." << std::endl;
811 std::cout <<
"Setting support for cropped images: " << ((
outputCroppedTiff == 1) ?
"yes" :
"no") << std::endl;
821 std::cout <<
"Setting blender type to \"ENBLEND\"." << std::endl;
828 std::cout <<
"Setting blender type to \"INTERNAL\"." << std::endl;
832 std::cout <<
"Blender \"" <<
blender <<
"\" is not a valid blender ." << std::endl
833 <<
"Ignoring parameter." << std::endl;
841 switch (
opt.blendMode)
845 std::cout <<
"Setting enblend arguments to " <<
blenderArgs << std::endl;
849 std::cout <<
"Setting verdandi arguments to " <<
blenderArgs << std::endl;
852 std::cout <<
"Unknown blender in pto file." << std::endl;
861 std::cout <<
"Setting enfuse arguments to " <<
fusionArgs << std::endl;
868 std::cout <<
"Setting hugin_hdrdmerge arguments to " <<
hdrMergeArgs << std::endl;
878 std::cout <<
"Setting ldr output to filetype \"" <<
ldrfiletype <<
"\"." << std::endl;
883 std::cout <<
"LDR file format \"" <<
ldrfiletype <<
"\" is not a valid LDR output filetype." << std::endl
884 <<
"Ignoring parameter." << std::endl;
891 if (
opt.outputImageType ==
"tif")
896 std::cout <<
"Setting TIF compression to \"" <<
ldrcompression <<
"\"." << std::endl;
901 std::cout <<
"LDR compression \"" <<
ldrcompression <<
"\" is not a valid compression value for TIF files." << std::endl
902 <<
"Ignoring compression." << std::endl;
907 if (
opt.outputImageType ==
"jpg")
913 if (quality>0 && quality <=100)
915 opt.quality = quality;
916 std::cout <<
"Setting JPEG quality to " << quality <<
"." << std::endl;
920 std::cout <<
"Given value for JPEG quality is outside the valid range 1..100." << std::endl
921 <<
"Ignoring value." << std::endl;
926 std::cout <<
"Could not parse \"" <<
ldrcompression <<
"\" as a valid JPEG quality number." << std::endl
927 <<
"Ignoring value." << std::endl;
932 if (
opt.outputImageType ==
"png")
934 std::cout <<
"Setting compression for PNG images is not supported." << std::endl;
939 std::cout <<
"Unknown image format" << std::endl;
952 std::cout <<
"Setting hdr output to filetype \"" <<
hdrfiletype <<
"\"." << std::endl;
957 std::cout <<
"HDR file format \"" <<
hdrfiletype <<
"\" is not a valid HDR output filetype." << std::endl
958 <<
"Ignoring parameter." << std::endl;
965 if (
opt.outputImageTypeHDR ==
"tif")
970 std::cout <<
"Setting HDR-TIF compression to \"" <<
hdrcompression <<
"\"." << std::endl;
974 std::cout <<
"HDR compression \"" <<
hdrcompression <<
"\" is not a valid compression value for TIF files." << std::endl
975 <<
"Ignoring compression." << std::endl;
980 if (
opt.outputImageTypeHDR ==
"exr")
982 std::cout <<
"Setting compression for EXR images is not supported." << std::endl;
987 std::cout <<
"Unknown HDR image format" << std::endl;
993 if (std::abs(yaw) + std::abs(pitch) + std::abs(roll) > 0.0)
995 std::cout <<
"Rotate panorama (yaw=" << yaw <<
", pitch= " << pitch <<
", roll=" << roll <<
")" << std::endl;
999 if(std::abs(x) + std::abs(y) + std::abs(z) > 0.0)
1001 std::cout <<
"Translate panorama (x=" << x <<
", y=" << y <<
", z=" << z <<
")" << std::endl;
1007 std::cout <<
"Straighten panorama" << std::endl;
1014 std::cout <<
"Center panorama" << std::endl;
1020 std::cout <<
"Fit panorama field of view to best size" << std::endl;
1026 std::cout <<
"Setting field of view to " <<
opt.getHFOV() <<
" x " <<
opt.getVFOV() << std::endl;
1038 std::cout <<
"Setting field of view to " <<
opt.getHFOV() <<
" x " <<
opt.getVFOV() << std::endl;
1044 std::cout <<
"Calculate optimal size of panorama" << std::endl;
1048 std::cout <<
"Setting canvas size to " <<
opt.getWidth() <<
" x " <<
opt.getHeight() << std::endl;
1057 std::cout <<
"Setting canvas size to " <<
opt.getWidth() <<
" x " <<
opt.getHeight() << std::endl;
1063 std::cout <<
"Searching for best crop rectangle" << std::endl;
1087 std::cout <<
"Set crop size to " <<
roi.left() <<
"," <<
roi.top() <<
"," <<
roi.right() <<
"," <<
roi.bottom() << std::endl;
1092 std::cout <<
"Could not find best crop rectangle" << std::endl;
1100 std::cout <<
"Set crop size to " <<
opt.getROI().left() <<
"," <<
opt.getROI().right() <<
"," <<
opt.getROI().top() <<
"," <<
opt.getROI().bottom() << std::endl;
1112 std::cout <<
"Set crop size to " <<
opt.getROI().left() <<
"," <<
opt.getROI().right() <<
"," <<
opt.getROI().top() <<
"," <<
opt.getROI().bottom() << std::endl;
1120 std::cout <<
"Set interpolation method to " <<
interpolation << std::endl;
1126 std::cout <<
"Reading panorama options from " <<
iniFile << std::endl;
1139 std::cout <<
"Applying settings from " <<
templateFile << std::endl;
1147 std::cout << std::endl <<
"Written output to " <<
output << std::endl;
declaration of functions to handle stacks and layers
HuginBase::PanoramaOptions ReadPanoramaOptionsFromIni(const std::string &iniFile, HuginBase::Panorama &pano)
read settings from given ini file and apply wished settings if they are applicable
read settings from ini file and apply only applicable values
Dummy progress display, without output.
virtual double getResultHorizontalFOV()
virtual double getResultHeight()
static double calcMeanExposure(const PanoramaData &pano)
static double calcOptimalScale(PanoramaData &panorama)
virtual void run()
runs the algorithm.
void setHFOV(double h, bool keepView=true)
set the horizontal field of view.
void setProjection(ProjectionFormat f)
set the Projection format and adjust the hfov/vfov if nessecary
BlendingMechanism blendMode
vigra_ext::Interpolator interpolator
std::string hdrmergeOptions
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true
void setROI(const vigra::Rect2D &val)
bool outputLDRBlended
save blended panorama (LDR)
double outputExposureValue
std::string enblendOptions
ProjectionFormat
Projection of final panorama.
std::string outputImageType
double outputRangeCompression
std::string outputImageTypeHDRCompression
std::string enfuseOptions
pano_projection_features m_projFeatures
std::string outputImageTypeHDR
std::string outputImageTypeCompression
const PanoramaOptions & getOptions() const
returns the options for this panorama
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...
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
UIntSet getActiveImages() const
get active images
TDiff2D< double > FDiff2D
std::string toupper(const std::string &s)
std::vector< std::string > SplitString(const std::string &s, const std::string &sep)
split string s at given sep, returns vector of strings
std::string StrTrim(const std::string &str)
remove trailing and leading white spaces and tabs
std::string tolower(const std::string &s)
convert a string to lowercase
std::string GetHuginVersion()
return a string with version numbers
bool FileExists(const std::string &filename)
checks if file exists
bool stringToDouble(const STR &str_, double &dest)
convert a string to a double, ignore localisation.
std::string GetOutputFilename(const std::string &out, const std::string &in, const std::string &suffix)
construct output filename, if ouput is known return this value otherwise use the input filename and a...
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.
bool stringToInt(const std::string &s, int &val)
convert string to integer value, returns true, if sucessful
Interpolator
enum with all interpolation methods
int main(int argc, char *argv[])
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.