Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

keygroup.cc

Go to the documentation of this file.
00001 #include "keygroup.h"
00002 #include "keypoint.h"
00003 #include "model.h"
00004 #include "object.h"
00005 #include <limits>
00006 
00007 int keygroup::keygroupID = 0;
00008 
00009 keygroup::keygroup(int ID) : id(ID), M(NULL), neighbors(), keypts() {}
00010 
00011 bool keygroup::isNeighbor(keygroup *g) {
00012   for (int i = 0; i < (int)neighbors.size(); i++)
00013     if (g == neighbors[i]) return true;
00014   
00015   return false;
00016 }
00017 int keygroup::compareTo(keygroup *g) {
00018   double sum = 0;
00019   for(size_t i = 0; i < keypts.size(); i++)
00020     sum = sum + (*keypts[i]).sqDist(*g->keypts[i]);
00021   return (int)sum;
00022 }
00023 int keygroup::compareTo(std::vector<keypoint*>* keypoints) {
00024   double sum = 0;
00025   for(size_t i = 0; i < keypts.size(); i++)
00026     sum = sum + (*keypts[i]).sqDist(*(*keypoints)[i]);
00027   return (int)sum;
00028 }
00029 keypoint* keygroup::bestMatchInGroup(keypoint* key, double* sqDist){
00030   keypoint *bestKey = NULL;
00031   double bestSqDist = std::numeric_limits<double>::infinity();
00032   for (int i = 0; i < (int)keypts.size(); i++){
00033     double d = key->sqDist(*(keypts[i]));
00034     if (d < bestSqDist){
00035       bestSqDist = d;
00036       bestKey = keypts[i];
00037     }
00038   }
00039   *sqDist = bestSqDist;
00040   return bestKey;
00041 }
00042 
00043 void keygroup::writeToFile(std::ofstream& outfile){
00044   outfile << id << std::endl;
00045   outfile << M->O->getID() << "\t" << M->getID() << std::endl;
00046   outfile << neighbors.size() << std::endl;
00047   for (unsigned int i = 0; i < neighbors.size(); i++){
00048     outfile << neighbors[i]->M->O->getID() << "\t" << neighbors[i]->M->getID() << "\t" << neighbors[i]->getID() << "\t";
00049   }
00050   outfile << std::endl;
00051   outfile << keypts.size() << std::endl;
00052   for (unsigned int i = 0; i < keypts.size(); i++){
00053     outfile << keypts[i]->getID() << "\t";
00054   }
00055   outfile << std::endl;
00056 }

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:42 2016 by Doxygen 1.6.3