38 double x1, y1, x2, y2;
83 std::vector<hugin_utils::FDiff2D> points;
84 for(
int dx=-5; dx<=5; dx++)
86 for(
int dy=-5; dy<=5; dy++)
94 for(
size_t i=0; i<points.size(); i++)
96 if(
CheckAndAddPoint(pano, img1, img2, transform1, transform2, mid.
x+points[i].x, mid.
y+points[i].y))
113 bool hasControlPoints=
false;
114 for (HuginBase::CPVector::const_iterator it = cp.begin(); it != cp.end(); ++it)
118 hasControlPoints=
true;
124 imgsWithCp.insert(i);
128 imgsWithoutCp.insert(i);
133 for (HuginBase::UIntSet::const_iterator img = imgsWithoutCp.begin(); img != imgsWithoutCp.end(); ++img)
136 bool connected=
false;
137 if(img1.YawisLinked())
139 for (HuginBase::UIntSet::const_iterator img2 = imgsWithCp.begin(); img2 != imgsWithCp.end(); ++img2)
141 if(img1.YawisLinkedWith(pano.
getImage(*img2)))
143 imgsWithCp.insert(*img);
151 imgsToTest.insert(*img);
156 if(imgsToTest.empty())
158 std::cout <<
"No unconnected images found." << std::endl
159 <<
"No control point added." << std::endl;
162 std::cout << std::endl <<
"Found " << imgsToTest.size() <<
" unconnected images." << std::endl;
168 std::vector<HuginBase::UIntSet> checkedImgPairs(pano.
getNrOfImages());
169 for (HuginBase::UIntSet::const_iterator img = imgsToTest.begin(); img != imgsToTest.end(); ++img)
179 if(overlap.
getOverlap(*img, i)>minOverlap/100.0f)
182 bool ignoreImage=
false;
184 if(img2.YawisLinked())
186 for (HuginBase::UIntSet::const_iterator it = overlappingImgs.begin(); it != overlappingImgs.end(); ++it)
188 if(img2.YawisLinkedWith(pano.
getImage(*it)))
201 overlappingImgs.insert(i);
202 checkedImgPairs[*img].insert(i);
203 checkedImgPairs[i].insert(*img);
208 for (HuginBase::UIntSet::const_iterator overlapImg = overlappingImgs.begin(); overlapImg != overlappingImgs.end(); ++overlapImg)
213 std::cout <<
"Added " << pano.
getCtrlPoints().size() - cp.size() <<
" control points." << std::endl;
231 if(img1.YawisLinked())
233 if(img1.YawisLinkedWith(pano.
getImage(j)))
238 if(overlap.
getOverlap(i, j)>=minOverlap/100.0f)
241 bool hasControlPoints=
false;
242 for (HuginBase::CPVector::const_iterator it = cp.begin(); it != cp.end(); ++it)
244 if(((it->image1Nr==i && it->image2Nr==j) ||
245 (it->image1Nr==j && it->image2Nr==i) ) &&
248 hasControlPoints=
true;
252 if(!hasControlPoints)
255 bool ignoreImage=
false;
257 if(img2.YawisLinked())
259 for (HuginBase::UIntSet::const_iterator it = overlappingImgs.begin(); it != overlappingImgs.end(); ++it)
261 if(img2.YawisLinkedWith(pano.
getImage(*it)))
270 overlappingImgs.insert(j);
276 for (HuginBase::UIntSet::const_iterator overlapImg = overlappingImgs.begin(); overlapImg != overlappingImgs.end(); ++overlapImg)
281 std::cout << std::endl <<
"Added " << pano.
getCtrlPoints().size() - cp.size() <<
" control points." << std::endl;
286 std::cout << name <<
": set geometric control points" << std::endl
289 <<
"Usage: " << name <<
" [options] input.pto" << std::endl
291 <<
" Options:" << std::endl
292 <<
" -o, --output=file.pto Output Hugin PTO file. Default: <filename>_geo.pto" << std::endl
293 <<
" -e, --each-overlap By default, geocpset will only work on the overlap" << std::endl
294 <<
" of unconnected images. With this switch it will" << std::endl
295 <<
" work on all overlaps without control points." << std::endl
296 <<
" --minimum-overlap=NUM Take only these images into account where the" << std::endl
297 <<
" overlap is bigger than NUM percent (default 10)." << std::endl
298 <<
" -h, --help Shows this help" << std::endl
302 int main(
int argc,
char* argv[])
305 const char* optstring =
"o:eh";
311 static struct option longOptions[] =
313 {
"output", required_argument, NULL,
'o' },
314 {
"each-overlap", no_argument, NULL,
'e' },
315 {
"min-overlap", required_argument, NULL, MINOVERLAP},
316 {
"help", no_argument, NULL,
'h' },
321 bool eachOverlap=
false;
324 while ((c = getopt_long (argc, argv, optstring, longOptions,
nullptr)) != -1)
335 minOverlap=atoi(optarg);
336 if(minOverlap<1 || minOverlap>99)
339 <<
"Minimum overlap have to be between 1 and 99." << std::endl;
357 if (argc - optind != 1)
359 if (argc - optind < 1)
370 std::string input=argv[optind];
380 std::cerr <<
"error: project file contains only one image" << std::endl
381 <<
"aborting processing" << std::endl;
385 std::cout <<
"Adding geometric control points..." << std::endl;
400 std::cout << std::endl <<
"Written output to " << output << std::endl;
void SetGeometricControlPointsUnconnected(HuginBase::Panorama &pano, const int minOverlap)
double getOverlap(unsigned int i, unsigned int j) const
returns the overlap for 2 images with number i and j
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...
void SetGeometricControlPointsOverlap(HuginBase::Panorama &pano, const int minOverlap)
vigra::Rect2D estimateOutputROI(const PanoramaData &pano, const PanoramaOptions &opts, unsigned i, const double maxLength)
unsigned int getHeight() const
get panorama height
bool CheckAndAddPoint(HuginBase::Panorama &pano, size_t img1, size_t img2, HuginBase::PTools::Transform &transform1, HuginBase::PTools::Transform &transform2, double x, double y)
bool set_contains(const _Container &c, const typename _Container::key_type &key)
void calculate(unsigned int steps)
does the calculation, for each image steps*steps points are extracted and tested with all other image...
const CPVector & getCtrlPoints() const
get all control point of this Panorama
bool isInside(vigra::Point2D p, bool ignoreMasks=false) const
check if a coordinate is inside the source image
represents a control point
std::set< unsigned int > UIntSet
unsigned int addCtrlPoint(const ControlPoint &point)
add a new control point.
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
std::size_t getNrOfImages() const
number of images.
bool sortByDistance(hugin_utils::FDiff2D p1, hugin_utils::FDiff2D p2)
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 setROI(const vigra::Rect2D &val)
T squareLength() const
Return the square of the length of the vector.
unsigned int getWidth() const
const PanoramaOptions & getOptions() const
returns the options for this panorama
void AddGeometricControlPoint(HuginBase::Panorama &pano, size_t img1, size_t img2)
definitions of classes to calculate overlap between different images
std::string GetHuginVersion()
return a string with version numbers
std::vector< ControlPoint > CPVector
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
class for calculating overlap of images
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
All variables of a source image.
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
void limitToImages(UIntSet img)
limits the calculation of the overlap to given image numbers
int main(int argc, char *argv[])