52 const std::size_t pos = text.find_first_of(
"=", 0);
53 if (pos == std::string::npos)
63 if (pos > 0 && pos < text.length() - 1)
65 std::string tempString(text.substr(0, pos));
70 tempString = text.substr(pos + 1, text.length() - pos - 1);
82 varVec.push_back(var);
90 for(
size_t i=0; i<splitResult.size(); i++)
97 void NewPart(
HuginBase::Panorama& pano, std::set<HuginBase::ImageVariableGroup::ImageVariableEnum> vars,
unsigned int imgNr)
99 for (std::set<HuginBase::ImageVariableGroup::ImageVariableEnum>::iterator it = vars.begin(); it != vars.end(); ++it)
103 #define image_variable( name, type, default_value )\
104 case HuginBase::ImageVariableGroup::IVE_##name:\
105 pano.unlinkImageVariable##name(imgNr);\
108 #undef image_variable
115 std::cout << name <<
": modify assigned lenses and stack in pto files" << std::endl
118 <<
"Usage: " << name <<
" [options] --switches imglist input.pto" << std::endl
120 <<
" -o, --output=file.pto Output Hugin PTO file. Default: <filename>_lens.pto" << std::endl
121 <<
" -h, --help Shows this help" << std::endl
123 <<
" --new-lens imglist Assign to given images a new lens number" << std::endl
124 <<
" --new-stack imglist Assign to given images a new stack number" << std::endl
125 <<
" Examples:" << std::endl
126 <<
" --new-lens i2 Image 2 gets a new lens" << std::endl
127 <<
" --new-stack i4,i5 Images 4 and 5 get a new stack" << std::endl
129 <<
" --change-lens imglist Assign to given images a new lens number" << std::endl
130 <<
" --change-stack imglist Assign to given images a new stack number" << std::endl
131 <<
" Examples:" << std::endl
132 <<
" --change-lens i2=0 Image 2 is assigned lens number 0" << std::endl
133 <<
" --change-stack i4=0,i5=1 Image 4 is assigned to stack 0," << std::endl
134 <<
" image 5 to stack number 1" << std::endl
138 int main(
int argc,
char* argv[])
141 const char* optstring =
"o:h";
145 SWITCH_NEW_LENS=1000,
150 static struct option longOptions[] =
152 {
"output", required_argument, NULL,
'o' },
153 {
"new-lens", required_argument, NULL, SWITCH_NEW_LENS },
154 {
"new-stack", required_argument, NULL, SWITCH_NEW_STACK },
155 {
"change-lens", required_argument, NULL, SWITCH_CHANGE_LENS },
156 {
"change-stack", required_argument, NULL, SWITCH_CHANGE_STACK },
157 {
"help", no_argument, NULL,
'h' },
167 while ((c = getopt_long (argc, argv, optstring, longOptions,
nullptr)) != -1)
177 case SWITCH_NEW_LENS:
180 case SWITCH_NEW_STACK:
183 case SWITCH_CHANGE_LENS:
186 case SWITCH_CHANGE_STACK:
200 if (argc - optind != 1)
202 if (argc - optind < 1)
213 if(newLensImgs.size() + newStackImgs.size() + changeLensImgs.size() + changeStackImgs.size()==0)
219 std::string input=argv[optind];
228 if(!newLensImgs.empty())
233 for(
size_t i=0; i<newLensImgs.size(); i++)
236 if(newLensImgs[i].imgNr<0 || newLensImgs[i].imgNr>=(
int)pano.
getNrOfImages())
240 std::cout <<
"Assigning a new lens to image " << newLensImgs[i].imgNr << std::endl;
246 std::cout <<
"Warning: Pto project contains already for each image an own lens" << std::endl
247 <<
" Nothing to do." << std::endl;
249 std::cout << std::endl;
253 if(!newStackImgs.empty())
258 for(
size_t i=0; i<newStackImgs.size(); i++)
261 if(newStackImgs[i].imgNr<0 || newStackImgs[i].imgNr>=(
int)pano.
getNrOfImages())
265 std::cout <<
"Assigning a new stack to image " << newStackImgs[i].imgNr << std::endl;
271 std::cout <<
"Warning: Pto project contains already for each image an own stack" << std::endl
272 <<
" Nothing to do." << std::endl;
274 std::cout << std::endl;
278 if(!changeLensImgs.empty())
284 for(
size_t i=0; i<changeLensImgs.size(); i++)
287 if(changeLensImgs[i].imgNr<0 || changeLensImgs[i].imgNr>=(
int)pano.
getNrOfImages())
291 if(changeLensImgs[i].lensStackNr<0 || changeLensImgs[i].lensStackNr>=lensCount)
299 std::cout <<
"Assigning image " << changeLensImgs[i].imgNr <<
" to lens " << changeLensImgs[i].lensStackNr << std::endl;
300 group.
switchParts(changeLensImgs[i].imgNr, changeLensImgs[i].lensStackNr);
304 std::cout <<
"Warning: Image size of image " << changeLensImgs[i].imgNr <<
" is " << pano.
getImage(changeLensImgs[i].imgNr).getSize() << std::endl
305 <<
" while images of lens " << changeLensImgs[i].lensStackNr <<
" have a size of " << pano.
getImage(*group.
getPartsSet()[changeLensImgs[i].lensStackNr].begin()).
getSize() <<
"." << std::endl
306 <<
" All images of the same lens must have the same size." << std::endl
307 <<
" So skipping this image." << std::endl;
313 std::cout <<
"Warning: Pto project contains only one lens." << std::endl
314 <<
" Therefore the lens can not be changed. Use --new-lens instead." << std::endl;
316 std::cout << std::endl;
320 if(!changeStackImgs.empty())
326 for(
size_t i=0; i<changeStackImgs.size(); i++)
329 if(changeStackImgs[i].imgNr<0 || changeStackImgs[i].imgNr>=(
int)pano.
getNrOfImages())
333 if(changeStackImgs[i].lensStackNr<0 || changeStackImgs[i].lensStackNr>=stackCount)
341 std::cout <<
"Assigning image " << changeStackImgs[i].imgNr <<
" to stack " << changeStackImgs[i].lensStackNr << std::endl;
342 group.
switchParts(changeStackImgs[i].imgNr, changeStackImgs[i].lensStackNr);
346 std::cout <<
"Warning: Image size of image " << changeStackImgs[i].imgNr <<
" is " << pano.
getImage(changeStackImgs[i].imgNr).getSize() << std::endl
347 <<
" while images of stack " << changeStackImgs[i].lensStackNr <<
" have a size of " << pano.
getImage(*group.
getPartsSet()[changeStackImgs[i].lensStackNr].begin()).
getSize() <<
"." << std::endl
348 <<
" All images of the same stack must have the same size." << std::endl
349 <<
" So skipping this image." << std::endl;
355 std::cout <<
"Warning: Pto project contains only one stack." << std::endl
356 <<
" Therefore the stack can not be changed. Use --new-stack instead." << std::endl;
358 std::cout << std::endl;
366 std::cout << std::endl <<
"Written project file " << output << std::endl;
static const std::set< ConstImageVariableGroup::ImageVariableEnum > & getLensVariables()
Get the set of lens image variables.
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...
ImageVariableGroup & getStacks()
Get the ImageVariableGroup representing the group of stack variables.
Somewhere to specify what variables belong to what.
options getSize().area()) int wxCALLBACK SortFieldOfViewAscending(wxIntPtr item1
UIntSetVector getPartsSet() const
return a vector which contains a HuginBase::UIntSet for each group with the corresponding images numb...
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 stringToInt(const std::string &s, int &val)
convert string to integer value, returns true, if sucessful
Same as above, but use a non const panorama.
std::string GetHuginVersion()
return a string with version numbers
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
std::vector< std::string > SplitString(const std::string &s, const std::string &sep)
split string s at given sep, returns vector of strings
std::size_t getNumberOfParts() const
get the number of parts.
void switchParts(unsigned int ImageNr, unsigned int partNr)
switch a given image to a different part number.
This file specifies what image variables SrcPanoImg should have.
void ParseImageLensStackString(ParseImgVec &parseVec, std::string input)
std::vector< ParsedImg > ParseImgVec
static const std::set< ConstImageVariableGroup::ImageVariableEnum > & getStackVariables()
Get the set of stack image variables.
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
void ParseSingleImage(ParseImgVec &varVec, const std::string &s)
int main(int argc, char *argv[])