27 #include <hugin_config.h>
39 static void usage(
const char* name)
41 std::cout << name <<
": Try to determine the radial vignetting" << std::endl
44 <<
"Usage: " << name <<
" [options] -o output.pto input.pto" << std::endl
45 <<
"Valid options are:" << std::endl
46 <<
" -o|--output file write results to output project" << std::endl
47 <<
" -v|--verbose Verbose, print progress messages" << std::endl
48 <<
" -p n Number of points to extract" << std::endl
49 <<
" -s level Work on downscaled images, every step halves width and height" << std::endl
50 <<
" -h|--help Display help (this text)" << std::endl
52 <<
" Expert and debugging options:" << std::endl
53 <<
" -i file Read corresponding points from file" << std::endl
54 <<
" -w file Dump corresponding points to file" << std::endl;
69 void loadPointsC(FILE* f, std::vector<vigra_ext::PointPairRGB>& vec)
71 double dummy1, dummy2;
78 n = fscanf(f,
" %lf %lf %lf %lf %lf %lf %f %f %f %f %f %f %lf %f %f %lf",
79 &i1, &i2, &(point.
p1.
x), &(point.
p1.
y),
80 &(point.
p2.
x), &(point.
p2.
y),
81 &(point.
i1.red()), &(point.
i1.green()), &(point.
i1.blue()),
82 &(point.
i2.red()), &(point.
i2.green()), &(point.
i2.blue()),
85 &(point.
r1), &(point.
r2),
100 void loadPoints(std::istream& i, std::vector<vigra_ext::PointPairRGB>& vec )
102 while(!i.eof() && i.good())
104 double dummy1, dummy2;
108 >> point.
p1.
x >> point.
p1.
y
109 >> point.
p2.
x >> point.
p2.
y
110 >> point.
i1.red() >> point.
i1.green() >> point.
i1.blue()
111 >> point.
i2.red() >> point.
i2.green() >> point.
i2.blue()
114 >> point.
r1 >> point.
r2
121 vec.push_back(point);
130 for (HuginBase::OptimizeVector::const_iterator it = vars.begin(); it != vars.end(); ++it)
132 for (std::set<std::string>::const_iterator itv = (*it).begin();
133 itv != (*it).end(); ++itv)
135 if ((*itv)[0] ==
'E' || (*itv)[0] ==
'R' || (*itv)[0] ==
'V')
145 int main(
int argc,
char* argv[])
150 const char* optstring =
"hi:o:p:s:vw:";
151 static struct option longOptions[] =
153 {
"output", required_argument, NULL,
'o' },
154 {
"verbose", no_argument, NULL,
'v' },
155 {
"help", no_argument, NULL,
'h' },
163 std::string outputFile;
164 std::string outputPointsFile;
165 std::string inputPointsFile;
166 while ((c = getopt_long(argc, argv, optstring, longOptions,
nullptr)) != -1)
171 inputPointsFile = optarg;
177 nPoints = atoi(optarg);
180 pyrLevel = atoi(optarg);
189 outputPointsFile = optarg;
202 unsigned nFiles = argc - optind;
216 const char* scriptFile = argv[optind];
226 std::cerr <<
"ERROR:no photometric parameters were selected for optimization" << std::endl;
227 std::cerr <<
"please update 'v' line in .pto script and try again." << std::endl;
232 TIFFSetWarningHandler(0);
237 std::vector<vigra_ext::PointPairRGB> points;
239 float imageStepSize = 1 / 255.0f;
240 if (inputPointsFile !=
"" )
244 FILE* f = fopen(inputPointsFile.c_str(),
"r");
247 perror(
"Could not open input point file");
259 std::cout <<
"\rSelected " << points.size() <<
" points" << std::endl;
263 std::cerr <<
"Error: no overlapping points found, exiting" << std::endl;
267 if (!outputPointsFile.empty())
269 std::ofstream of(outputPointsFile.c_str());
270 for (std::vector<vigra_ext::PointPairRGB>::iterator it = points.begin(); it != points.end(); ++it)
272 of << (*it).imgNr1 <<
" " << (*it).imgNr2 <<
" "
273 << (*it).p1.x <<
" " << (*it).p1.y<<
" "
274 << (*it).p2.x <<
" " << (*it).p2.y<<
" "
275 << (*it).i1.red() <<
" " << (*it).i1.green() <<
" " << (*it).i1.blue() <<
" "
276 << (*it).i2.red() <<
" " << (*it).i2.green() <<
" " << (*it).i2.blue() <<
" "
279 << (*it).r1 <<
" " << (*it).r2 <<
" "
286 progressDisplay.
setMessage(
"Vignetting Optimization");
298 catch (std::exception& e)
300 std::cerr <<
"caught exception: " << e.what() << std::endl;
bool hasphotometricParams(HuginBase::Panorama &pano)
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...
virtual void run()
runs the algorithm.
void loadPointsC(FILE *f, std::vector< vigra_ext::PointPairRGB > &vec)
void taskFinished()
call when a task has finished and the status message should be cleared
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
const OptimizeVector & getOptimizeVector() const
return the optimize settings stored inside 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 setMessage(const std::string &message, const std::string &filename="")
sets the message to given string
Contains various routines used for stitching panoramas.
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
std::vector< std::set< std::string > > OptimizeVector
a progress display to print progress reports to a stream
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
void loadPoints(std::istream &i, std::vector< vigra_ext::PointPairRGB > &vec)
int main(int argc, char *argv[])