40 static void usage(
const char* name)
42 std::cout << name <<
": remove wrong control points by statistic method" << std::endl
45 <<
"Usage: " << name <<
" [options] input.pto" << std::endl
47 <<
"CPClean uses statistical methods to remove wrong control points" << std::endl << std::endl
48 <<
"Step 1 optimises all images pairs, calculates for each pair mean " << std::endl
49 <<
" and standard deviation and removes all control points " << std::endl
50 <<
" with error bigger than mean+n*sigma" << std::endl
51 <<
"Step 2 optimises the whole panorama, calculates mean and standard deviation" << std::endl
52 <<
" for all control points and removes all control points with error" << std::endl
53 <<
" bigger than mean+n*sigma" << std::endl << std::endl
54 <<
" Options:" << std::endl
55 <<
" --output|-o file.pto Output Hugin PTO file." << std::endl
56 <<
" Default: '<filename>_clean.pto'." << std::endl
57 <<
" --max-distance|-n num distance factor for checking (default: 2)" << std::endl
58 <<
" (cps with an error > mean + this factor*sigma" << std::endl
59 <<
" will be removed)" << std::endl
60 <<
" --pairwise-checking|-p do only images pairs cp checking (skip step 2)" << std::endl
61 <<
" --whole-pano-checking|-w do only whole panorama cp checking (skip step 1)" << std::endl
62 <<
" --dont-optimize|-s skip optimisation step when checking the" << std::endl
63 <<
" whole panorama (only step 2)" << std::endl
64 <<
" --check-line-cp|-l also include line control points for calculation" << std::endl
65 <<
" and filtering in step 2" << std::endl
66 <<
" --verbose|-v verbose output during optimisation"<<std::endl
67 <<
" --help|-h shows help" << std::endl
82 int main(
int argc,
char* argv[])
85 const char* optstring =
"o:hn:pwslv";
86 static struct option longOptions[] =
88 {
"output", required_argument, NULL,
'o'},
89 {
"max-distance", required_argument, NULL,
'n'},
90 {
"pairwise-checking", no_argument, NULL,
'p'},
91 {
"whole-pano-checking", no_argument, NULL,
'w'},
92 {
"dont-optimize", no_argument, NULL,
's'},
93 {
"check-line-cp", no_argument, NULL,
'l' },
94 {
"verbose", no_argument, NULL,
'v'},
95 {
"help", no_argument, NULL,
'h' },
100 bool onlyPair =
false;
101 bool wholePano =
false;
102 bool skipOptimisation =
false;
103 bool includeLineCp =
false;
104 bool verbose =
false;
106 while ((c = getopt_long(argc, argv, optstring, longOptions,
nullptr)) != -1)
120 std::cerr <<
hugin_utils::stripPath(argv[0]) <<
": Invalid parameter: " << optarg <<
" is not valid real number" << std::endl;
136 skipOptimisation =
true;
139 includeLineCp =
true;
155 if (argc - optind != 1)
157 if (argc - optind < 1)
168 if (onlyPair && wholePano)
174 std::string input=argv[optind];
185 std::cerr <<
"Panorama should consist of at least two images" << std::endl;
191 std::cerr <<
"Panorama should contain at least 3 control point" << std::endl;
200 size_t cpremoved1 = 0;
206 std::cout <<
"Step 1: Do image pair control point checking..." << std::endl;
208 if (!CPtoRemove.empty())
209 for (HuginBase::UIntSet::reverse_iterator it = CPtoRemove.rbegin(); it != CPtoRemove.rend(); ++it)
213 cpremoved1=CPtoRemove.size();
217 bool unconnected=
false;
226 std::cout <<
"Step 2: Do whole panorama control point checking..." << std::endl;
229 std::cout <<
" Skipping optimisation, current image positions will be used." << std::endl;
232 if (!CPtoRemove.empty())
233 for (HuginBase::UIntSet::reverse_iterator it = CPtoRemove.rbegin(); it != CPtoRemove.rend(); ++it)
240 std::cout <<
"Skipping whole panorama checking because of unconnected image groups" << std::endl;
244 std::cout << std::endl;
247 std::cout <<
"Removed " << cpremoved1 <<
" control points in step 1" << std::endl;
253 std::cout <<
"Skipped step 2 because of unconnected image pairs" << std::endl;
257 std::cout <<
"Removed " << CPtoRemove.size() <<
" control points in step 2" << std::endl;
266 std::cout << std::endl <<
"Written output to " << output << std::endl;
static int ptProgress(int command, char *argument)
Dummy progress display, without output.
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...
bool IsConnected()
check if all images are connected
std::size_t getNrOfCtrlPoints() const
number of control points
std::set< unsigned int > UIntSet
algorithms for remove control points by statistic method
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
std::size_t getNrOfImages() const
number of images.
UIntSet getCPoutsideLimit_pair(Panorama pano, AppBase::ProgressDisplay &progress, double n)
optimises images pairwise and removes for every image pair control points with error > mean+n*sigma ...
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...
!! from PTOptimise.h 1951
UIntSet getCPoutsideLimit(Panorama pano, double n, bool skipOptimisation, bool includeLineCp)
optimises the whole panorama and removes all control points with error > mean+n*sigma ...
std::string GetHuginVersion()
return a string with version numbers
void removeCtrlPoint(unsigned int pNr)
remove a control point.
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
static int ptinfoDlg(int command, char *argument)
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[])
class to work with images graphs created from a HuginBase::Panorama class it creates a graph based on...