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
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
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 }