Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

keypoint.cc

Go to the documentation of this file.
00001 #include "keypoint.h"
00002 #include "keygroup.h"
00003 #include "model.h"
00004 #include "object.h"
00005 #include <iostream>
00006 
00007 using namespace std;
00008 
00009 int keypoint::keypointID = 0;
00010 
00011 keypoint::keypoint(int ID)
00012 : id(ID), G(NULL), modelX(-1), modelY(-1), modelScale(-1), modelOrientation(-1),
00013 imageX(-1), imageY(-1), imageScale(-1), imageOrientation(-1),
00014 imageIntScale(1), imageIntOctave(1), desc(), generation(-1),
00015 bestDist(), bestMatch(), finalMatch(NULL), matches(), modelMatches(), modelMatchErrors(),
00016 isInlier(false) {}
00017 
00018 double keypoint::sqDist(keypoint& key){
00019   double dist = 0.0;
00020   for (int i = 0; i < KEYPOINTDIM; i++){
00021     double diff = this->desc[i] - key.desc[i];
00022     dist += (diff * diff);
00023   }
00024   
00025   return dist;
00026 }
00027 
00028 void keypoint::print(){
00029   cout << "modelX:           " << modelX           << endl;
00030   cout << "modelY:           " << modelY           << endl;
00031   cout << "modelScale:       " << modelScale       << endl;
00032   cout << "modelOrientation: " << modelOrientation << endl;
00033   cout << "imageX:           " << imageX           << endl;
00034   cout << "imageY:           " << imageY           << endl;
00035   cout << "imageScale:       " << imageScale       << endl;
00036   cout << "imageOrientation: " << imageOrientation << endl;
00037   cout << "desc: (";
00038   int i;
00039   for (i = 0; i < KEYPOINTDIM - 1; i++){
00040     cout << desc[i] << ", ";
00041   }
00042   cout << desc[i] << ")\n";
00043 }
00044 
00045 
00046 void keypoint::writeToFile(std::ofstream& outfile, bool indicateDim){
00047   if (indicateDim) outfile << desc.size();
00048 }
00049 
00050 void keypoint::writeToFile(std::ofstream& outfile){
00051   outfile << id << endl;
00052   outfile << G->M->O->getID() << "\t" << G->M->getID() << "\t" << G->getID() << endl;
00053   //  outfile << valid << endl;
00054   outfile << imageX << "\t" << imageY << "\t" << imageScale << "\t" << imageOrientation << "\t" << imageIntScale << "\t" << imageIntOctave << endl;
00055   outfile << modelX << "\t" << modelY << "\t" << modelScale << "\t" << modelOrientation << endl;
00056   outfile << generation << endl;
00057   if (finalMatch == NULL){
00058     outfile << 0 << endl;
00059   }else{
00060     outfile << 1 << endl;
00061     outfile << finalMatch->id << endl;
00062   }
00063   outfile << matches.size() << endl;
00064   for (unsigned int i = 0; i < matches.size(); i++){
00065     outfile << matches[i]->id << "\t";
00066   }
00067   outfile << endl;
00068   outfile << desc.size() << endl;
00069   for (unsigned int i = 0; i < desc.size(); i++){
00070     outfile << desc[i] << "\t";
00071   }
00072   outfile << endl;
00073   //  outfile << bestDist.size() << endl;
00074   //  for (unsigned int i = 0; i < bestDist.size(); i++){
00075   //    outfile << bestDist[i] << "\t";
00076   //  }
00077   //  outfile << endl;
00078   //  outfile << bestMatch.size() << endl;
00079   //  for (unsigned int i = 0; i < bestMatch.size(); i++){
00080   //    outfile << "\t" << bestMatch[i]->G->M->O->getID() << "\t" << bestMatch[i]->G->M->getID() << "\t" << bestMatch[i]->G->getID() << "\t" << bestMatch[i]->getID();
00081   //  }
00082   //  outfile << endl;
00083   //  if (finalMatch == NULL){
00084   //    outfile << 0 << endl;
00085   //  }else{
00086   //    outfile << 1 << endl;
00087   //    outfile << finalMatch->G->M->O->getID() << "\t" << finalMatch->G->M->getID() << "\t" << finalMatch->G->getID() << "\t" << finalMatch->getID() << endl;
00088   //  }
00089   //  outfile << modelMatches.size() << endl;
00090   //  for (unsigned int i = 0; i < modelMatches.size(); i++){
00091   //    outfile << "\t" << modelMatches[i]->G->M->O->getID() << "\t" << modelMatches[i]->G->M->getID() << "\t" << modelMatches[i]->G->getID() << "\t" << modelMatches[i]->getID();
00092   //  }
00093   //  outfile << endl;
00094   //  outfile << modelMatchErrors.size() << endl;
00095   //  for (unsigned int i = 0; i < modelMatchErrors.size(); i++){
00096   //    outfile << modelMatchErrors[i] << "\t";
00097   //  }
00098   //  outfile << endl;
00099   //  outfile << isInlier << endl;
00100   
00101 }

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