/* * Copyright (C) 2009 Pablo d'Angelo * * This file is part of Panomatic. * * Panomatic is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Panomatic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Panomatic; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "KeyPointIO.h" using namespace lfeat; using namespace std; // extremly fagile check... static bool identifySIFTKeypoints( const std::string & filename) { ImageInfo info; ifstream in(filename.c_str()); if (!in) return false; int nKeypoints = 0; int dims = 0; in >> nKeypoints >> dims; return (cin && nKeypoints > 0 && dims >= 0); } static ImageInfo loadSIFTKeypoints( const std::string & filename, KeyPointVect_t & vec) { ImageInfo info; ifstream in(filename.c_str()); if (!in.good()) return info; int nKeypoints = 0; int dims = 0; in >> nKeypoints >> dims; info.dimensions = dims; for (int i = 0; i < nKeypoints; i++) { KeyPointPtr k(new lfeat::KeyPoint(0,0,0,0,0)); in >> k->_y >> k->_x >> k->_scale >> k->_ori >> k->_score; if (dims > 0) { k->allocVector(dims); for (int j=0; j < dims; j++) { in >> k->_vec[j]; } } vec.push_back(k); } // finish reading empty line std::getline(in, info.filename); // read line with filename std::getline(in, info.filename); in >> info.width >> info.height; //std::cerr << "*** Loaded keypoints for image " << info.filename << " ("<"<< endl; o << "\n"; o << " "<< imageinfo.width <<""<< endl; o << " "<< imageinfo.height <<""<< endl; o << " "<< imageinfo.filename <<""<< endl; o << " "<< endl; } void AutopanoSIFTWriter::writeKeypoint ( double x, double y, double scale, double orientation, double score, int dims, double * vec ) { o << " "<< endl; o << " "<< x <<""<"<< y <<""<"<< scale <<""<"<< orientation <<""< 0 ) { o << " "<< dims <<""<"<"<< ( vec[i]*256 ) << "" << endl; } o << " "<"<< endl; } void AutopanoSIFTWriter::writeFooter() { o << " "<< endl; o << ""<< endl; }