ViSP  2.10.0
vpBasicKeyPoint.h
1 /****************************************************************************
2  *
3  * $Id: vpBasicKeyPoint.h 4574 2014-01-09 08:48:51Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Key point used in matching algorithm.
36  *
37  * Authors:
38  * Nicolas Melchior
39  *
40  *****************************************************************************/
41 
42 
43 #ifndef vpBasicKeyPoint_H
44 #define vpBasicKeyPoint_H
45 
51 #include <visp/vpColor.h>
52 #include <visp/vpImage.h>
53 #include <visp/vpImagePoint.h>
54 #include <visp/vpRect.h>
55 
56 #include <vector>
57 
58 
68 class VISP_EXPORT vpBasicKeyPoint
69 {
70  public:
72 
73  virtual ~vpBasicKeyPoint() {
74  matchedReferencePoints.resize(0);
75  currentImagePointsList.resize(0);
76  referenceImagePointsList.resize(0);
77  };
78 
79  virtual unsigned int buildReference(const vpImage<unsigned char> &I) =0;
80 
81  virtual unsigned int buildReference(const vpImage<unsigned char> &I,
82  const vpImagePoint &iP,
83  const unsigned int height, const unsigned int width) =0;
84 
85  virtual unsigned int buildReference(const vpImage<unsigned char> &I,
86  const vpRect& rectangle) =0;
87 
88  virtual unsigned int matchPoint(const vpImage<unsigned char> &I) =0;
89 
90  virtual unsigned int matchPoint(const vpImage<unsigned char> &I,
91  const vpImagePoint &iP,
92  const unsigned int height, const unsigned int width) =0;
93 
94  virtual unsigned int matchPoint(const vpImage<unsigned char> &I,
95  const vpRect& rectangle) =0;
96 
97  virtual void display(const vpImage<unsigned char> &Iref,
98  const vpImage<unsigned char> &Icurrent, unsigned int size=3) =0;
99 
100  virtual void display(const vpImage<unsigned char> &Icurrent, unsigned int size=3,
101  const vpColor &color=vpColor::green) =0;
102 
108  bool referenceBuilt() const {return _reference_computed;}
109 
116  return &referenceImagePointsList[0];
117  } ;
118 
125  inline void getReferencePoint (const unsigned int index, vpImagePoint &referencePoint )
126  {
127  if (index >= referenceImagePointsList.size())
128  {
129  vpTRACE("Index of the reference point out of range");
130  throw(vpException(vpException::fatalError,"Index of the reference point out of range"));
131  }
132 
133  referencePoint.set_ij(referenceImagePointsList[index].get_i(), referenceImagePointsList[index].get_j());
134  }
135 
143  inline void getMatchedPoints(const unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint) {
144  if (index >= matchedReferencePoints.size())
145  {
146  vpTRACE("Index of the matched points out of range");
147  throw(vpException(vpException::fatalError,"Index of the matched points out of range"));
148  }
149  referencePoint.set_ij(referenceImagePointsList[matchedReferencePoints[index]].get_i(),referenceImagePointsList[matchedReferencePoints[index]].get_j());
150  currentPoint.set_ij(currentImagePointsList[index].get_i(), currentImagePointsList[index].get_j());
151  };
152 
173  inline unsigned int getIndexInAllReferencePointList ( const unsigned int indexInMatchedPointList ) {
174  if (indexInMatchedPointList >= matchedReferencePoints.size())
175  {
176  vpTRACE("Index of the matched reference point out of range");
177  throw(vpException(vpException::fatalError,"Index of the matched reference point out of range"));
178  }
179  return matchedReferencePoints[indexInMatchedPointList];
180  }
181 
187  inline unsigned int getReferencePointNumber() const {return (unsigned int)referenceImagePointsList.size();};
188 
194  inline unsigned int getMatchedPointNumber() const {return (unsigned int)matchedReferencePoints.size();};
195 
203  const std::vector<vpImagePoint>& getReferenceImagePointsList() const {return referenceImagePointsList;}
204 
212  const std::vector<vpImagePoint>& getCurrentImagePointsList() const {return currentImagePointsList;}
213 
223  const std::vector<unsigned int>& getMatchedReferencePoints() const {return matchedReferencePoints;}
224 
225  private:
226  virtual void init()=0;
227 
228  protected:
232  std::vector<vpImagePoint> referenceImagePointsList;
233 
238  std::vector<vpImagePoint> currentImagePointsList;
239 
246  std::vector<unsigned int> matchedReferencePoints;
247 
250 };
251 
252 #endif
253 
254 /*
255  * Local variables:
256  * c-basic-offset: 2
257  * End:
258  */
259 
class that defines what is a Keypoint. This class provides all the basic elements to implement classe...
unsigned int getIndexInAllReferencePointList(const unsigned int indexInMatchedPointList)
#define vpTRACE
Definition: vpDebug.h:418
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
error that can be emited by ViSP classes.
Definition: vpException.h:76
void getMatchedPoints(const unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint)
static const vpColor green
Definition: vpColor.h:170
bool referenceBuilt() const
bool _reference_computed
flag to indicate if the reference has been built.
const std::vector< vpImagePoint > & getCurrentImagePointsList() const
std::vector< vpImagePoint > referenceImagePointsList
const vpImagePoint * getAllPointsInReferenceImage()
void getReferencePoint(const unsigned int index, vpImagePoint &referencePoint)
std::vector< unsigned int > matchedReferencePoints
virtual ~vpBasicKeyPoint()
Defines a rectangle in the plane.
Definition: vpRect.h:85
std::vector< vpImagePoint > currentImagePointsList
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:93
const std::vector< vpImagePoint > & getReferenceImagePointsList() const
const std::vector< unsigned int > & getMatchedReferencePoints() const
unsigned int getMatchedPointNumber() const
void set_ij(const double ii, const double jj)
Definition: vpImagePoint.h:181
unsigned int getReferencePointNumber() const