CPVector AutoCtrlPointCreator::readUpdatedControlPoints(const std::string & file, PT::Panorama & pano) { ifstream stream(file.c_str()); if (! stream.is_open()) { DEBUG_ERROR("Could not open autopano output: " << file); return CPVector(); } Panorama tmpp; PanoramaMemento newPano; int ptoVersion = 0; newPano.loadPTScript(stream, ptoVersion, ""); tmpp.setMemento(newPano); // create mapping between the panorama images. map<unsigned int, unsigned int> imgMapping; for (unsigned int ni = 0; ni < tmpp.getNrOfImages(); ni++) { std::string nname = stripPath(tmpp.getImage(ni).getFilename()); for (unsigned int oi=0; oi < pano.getNrOfImages(); oi++) { std::string oname = stripPath(pano.getImage(oi).getFilename()); if (nname == oname) { // insert image imgMapping[ni] = oi; break; } } if (! set_contains(imgMapping, ni)) { DEBUG_ERROR("Could not find image " << ni << ", name: " << tmpp.getImage(ni).getFilename() << " in autopano output"); return CPVector(); } } // get control points CPVector ctrlPoints = tmpp.getCtrlPoints(); // make sure they are in correct order for (CPVector::iterator it= ctrlPoints.begin(); it != ctrlPoints.end(); ++it) { (*it).image1Nr = imgMapping[(*it).image1Nr]; (*it).image2Nr = imgMapping[(*it).image2Nr]; } return ctrlPoints; }
CPVector AutoCtrlPointCreator::readUpdatedControlPoints(const std::string & file, PT::Panorama & pano, const PT::UIntSet & imgs) { ifstream stream(file.c_str()); if (! stream.is_open()) { DEBUG_ERROR("Could not open control point detector output: " << file); return CPVector(); } Panorama tmpp; PanoramaMemento newPano; int ptoVersion = 0; newPano.loadPTScript(stream, ptoVersion, ""); tmpp.setMemento(newPano); //check if sizes matches if(tmpp.getNrOfImages()!=imgs.size()) { return CPVector(); }; // create mapping between the panorama images. vector<size_t> imgMapping(imgs.size()); size_t i=0; for(UIntSet::const_iterator it=imgs.begin();it!=imgs.end();it++) { imgMapping[i++]=*it; }; // get control points CPVector ctrlPoints = tmpp.getCtrlPoints(); // make sure they are in correct order for (CPVector::iterator it= ctrlPoints.begin(); it != ctrlPoints.end(); ++it) { (*it).image1Nr = imgMapping[(*it).image1Nr]; (*it).image2Nr = imgMapping[(*it).image2Nr]; } return ctrlPoints; }