38static void usage(
const char* name)
40 std::cout << name <<
": add mask to pto project" << std::endl
43 <<
"Usage: " << name <<
" [options] input.pto" << std::endl
45 <<
" Options:" << std::endl
46 <<
" -o, --output=file.pto Output Hugin PTO file. Default: <filename>_mask.pto" << std::endl
47 <<
" --mask=filename@imgNr Read the mask from the file and" << std::endl
48 <<
" assign the mask to given image" << std::endl
49 <<
" --rotate=CLOCKWISE|90|COUNTERCLOCKWISE|-90" << std::endl
50 <<
" Rotates the mask clock- or counterclockwise" << std::endl
51 <<
" --process==CLIP|SCALE|PROP_SCALE Specify how the mask should be modified" << std::endl
52 <<
" if the mask is create for an image with" << std::endl
53 <<
" different size." << std::endl
54 <<
" * CLIP: clipping (Default)" << std::endl
55 <<
" * SCALE: Scaling width and height individually" << std::endl
56 <<
" * PROP_SCALE: Proportional scale" << std::endl
57 <<
" --delete-mask=maskNr@imgNr|ALL@imgNr|ALL" << std::endl
58 <<
" Removes the specified mask(s)" << std::endl
59 <<
" -h, --help Shows this help" << std::endl
91 bool deleteAllMasks =
false;
106 size_t found=
s.rfind(
'@');
108 if(
found!=std::string::npos)
110 std::string
s2=
s.substr(
found+1, std::string::npos);
112 if(
mf.imageNr==0 &&
s2!=
"0")
136 if(
s==
"CLOCKWISE" ||
s==
"90")
142 if(
s==
"COUNTERCLOCKWISE" ||
s==
"-90")
188 deleteAllMasks =
true;
192 size_t found =
s.rfind(
'@');
193 if (
found != std::string::npos)
196 std::string
s2 =
s.substr(0,
found);
211 s2 =
s.substr(
found + 1, std::string::npos);
274 std::cout <<
"Deleting all masks in project file" << std::endl;
287 const unsigned int imgNr =
it->first;
296 std::cout <<
"Deleting all masks for image " << imgNr << std::endl;
304 if (*
maskNr < masks.size())
306 masks.erase(masks.begin() + (*maskNr));
307 std::cout <<
"Deleting mask " << *
maskNr <<
" for image " << imgNr << std::endl;
311 std::cout <<
"Ignoring deleting non-existing mask number " << *
maskNr <<
" for image " << imgNr << std::endl;
320 std::cout <<
"Ignoring deleting masks for invalid image nr " << imgNr << std::endl;
330 std::ifstream in(
maskFiles[
i].maskFile.c_str());
337 std::cerr <<
"Error: Could not parse mask from file \"" <<
maskFiles[
i].maskFile <<
"\"." << std::endl;
366 std::cout <<
"Clipping mask" << std::endl;
373 std::cout <<
"Scaling mask" << std::endl;
381 std::cout <<
"Propotional scale mask" << std::endl;
383 double factor=std::min((
double)imageSize.width()/
maskWidth, (
double)imageSize.height()/
maskHeight);
401 std::cout <<
"Warning: Invalid image number \"" <<
maskFiles[
i].imageNr <<
"\"." << std::endl
402 <<
" Project contains only " << pano.
getNrOfImages()+1 <<
" images." << std::endl
403 <<
" Ignoring this mask." << std::endl;
412 std::cout << std::endl <<
"Written project file " <<
output << std::endl;
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
void updateMasksForImage(unsigned int imgNr, MaskPolygonVector newMasks)
set complete mask list for image with number
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...
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
std::size_t getNrOfImages() const
number of images.
std::vector< MaskPolygon > MaskPolygonVector
const int maskOffset
polygon can exceed the image maximal maskOffset pixels in each direction bigger polygons will be clip...
std::set< unsigned int > UIntSet
std::string toupper(const std::string &s)
bool stringToUInt(const std::string &s, unsigned int &val)
convert string to unsigned integer value, returns true, if sucessful
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
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.
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.