1 #ifndef gra_FeaturePointsMatch_K_Match_H__
2 #define gra_FeaturePointsMatch_K_Match_H__
7 #include "../dsa/VP_Tree.h"
8 #include "../oo/ObjBase.h"
14 template<
class Scalar,
class Description>
17 # define FPMKM FeaturePointsMatch_K_Match
29 Node(Node
const& nd) {
41 bool operator<(Node
const& nd)
const {
42 return (id_ < nd.id_);
44 Description operator[](
size_t id)
const {
45 return (*ptr_)[id_][index_][id];
54 Myself(
size_t k): k_(k) {
56 Myself(Myself
const& m): k_(m.k_) {
62 Self<Myself>
const self;
71 FPMKM(
size_t k): self(Myself(k)) {
92 self()->k_ = std::max(k, (
size_t)1);
114 for (
size_t i = 0, I = to.size(); i < I; i++) {
115 for (
size_t j = 0, J = to[i].size(); j < J; j++) {
116 tree.
insert(Node(i, j, &to));
120 for (
size_t i = 0, I = from.size(); i < I; i++) {
121 for (
size_t j = 0, J = from[i].size(); j < J; j++) {
122 Node now(i, j, &from);
123 std::vector<Node> tree_ret = tree.query(now, self->k_,
true);
124 for (
size_t k = 0, K = tree_ret.size(); k < K; k++) {
127 tree_ret[k].index_));
138 for (
size_t i = 0, I = fpss.size(); i < I; i++) {
141 add =
match(dimension, fpss[i], to);
142 for (
size_t j = 0, J = add.size(); j < J; j++) {
144 add[j].to.first, add[j].to.second));
156 bool write(FILE* f,
bool bin,
unsigned int fg)
const {
161 bool read (FILE* f,
bool bin,
unsigned int fg) {
175 return typeid(*this).name();
179 return std::string(
ctype());
186 #endif // gra_FeaturePointsMatch_K_Match_H__
ObjBase * create() const
回傳一個new出來的物件, 預設implement為直接回傳 NULL
std::string type() const
用std::string回傳這個class的type name
FeaturePointIndexPairs match(size_t dimension, FeaturePoints const &from, FeaturePointss const &to) const
std::vector< FeaturePoint< Scalar, Description > > FeaturePoints
FeaturePointIndexPairs match(size_t dimension, FeaturePoints const &from, FeaturePoints const &to) const
std::vector< FeaturePoint< Scalar, Description > > FeaturePoints
FPMKM & operator=(FPMKM const &b)
void insert(Vector const &vector)
將給定的Vector加到set中
PairToPair< size_t, size_t, size_t, size_t > FeaturePointIndexPair
std::vector< FeaturePoints > FeaturePointss
FeaturePointIndexPairs match(size_t dimension, FeaturePointss const &from, FeaturePointss const &to) const
char const * ctype() const
用C-style string回傳這個class的type name
FPMKM & copyFrom(FPMKM const &m)
std::vector< FeaturePointIndexPair > FeaturePointIndexPairs
bool read(FILE *f, bool bin, unsigned int fg)
將物件從檔案讀出, 預設implement為直接回傳 false
一切物件的Base, 並要求每個物件都要有read, write, create, ... 等功能
ObjBase * copyFrom(ObjBase const *ptr)
複製, 預設使用operator=
std::vector< FeaturePoints > FeaturePointss
bool write(FILE *f, bool bin, unsigned int fg) const
將物件寫入檔案, 預設implement為直接回傳 false
FeaturePointIndexPairs match(size_t dimension, FeaturePointss const &fpss) const
A little class use for packing the data part of another class. With this technique, it can achieve Copy-On-Write(COR) mechanism at background and have a reference mechanism which much more flexible then the one C++ has.
FPMKM & referenceFrom(FPMKM const &m)