Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpBasicKeyPoint.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Key point used in matching algorithm.
32  *
33  * Authors:
34  * Nicolas Melchior
35  *
36  *****************************************************************************/
37 
38 
39 #ifndef vpBasicKeyPoint_H
40 #define vpBasicKeyPoint_H
41 
47 #include <visp3/core/vpColor.h>
48 #include <visp3/core/vpImage.h>
49 #include <visp3/core/vpImagePoint.h>
50 #include <visp3/core/vpRect.h>
51 
52 #include <vector>
53 
54 
63 class VISP_EXPORT vpBasicKeyPoint
64 {
65  public:
67 
68  virtual ~vpBasicKeyPoint() {
69  matchedReferencePoints.resize(0);
70  currentImagePointsList.resize(0);
71  referenceImagePointsList.resize(0);
72  };
73 
74  virtual unsigned int buildReference(const vpImage<unsigned char> &I) =0;
75 
76  virtual unsigned int buildReference(const vpImage<unsigned char> &I,
77  const vpImagePoint &iP,
78  const unsigned int height, const unsigned int width) =0;
79 
80  virtual unsigned int buildReference(const vpImage<unsigned char> &I,
81  const vpRect& rectangle) =0;
82 
83  virtual unsigned int matchPoint(const vpImage<unsigned char> &I) =0;
84 
85  virtual unsigned int matchPoint(const vpImage<unsigned char> &I,
86  const vpImagePoint &iP,
87  const unsigned int height, const unsigned int width) =0;
88 
89  virtual unsigned int matchPoint(const vpImage<unsigned char> &I,
90  const vpRect& rectangle) =0;
91 
92  virtual void display(const vpImage<unsigned char> &Iref,
93  const vpImage<unsigned char> &Icurrent, unsigned int size=3) =0;
94 
95  virtual void display(const vpImage<unsigned char> &Icurrent, unsigned int size=3,
96  const vpColor &color=vpColor::green) =0;
97 
103  bool referenceBuilt() const {return _reference_computed;}
104 
111  return &referenceImagePointsList[0];
112  } ;
113 
120  inline void getReferencePoint (const unsigned int index, vpImagePoint &referencePoint )
121  {
122  if (index >= referenceImagePointsList.size())
123  {
124  vpTRACE("Index of the reference point out of range");
125  throw(vpException(vpException::fatalError,"Index of the reference point out of range"));
126  }
127 
128  referencePoint.set_ij(referenceImagePointsList[index].get_i(), referenceImagePointsList[index].get_j());
129  }
130 
138  inline void getMatchedPoints(const unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint) {
139  if (index >= matchedReferencePoints.size())
140  {
141  vpTRACE("Index of the matched points out of range");
142  throw(vpException(vpException::fatalError,"Index of the matched points out of range"));
143  }
144  referencePoint.set_ij(referenceImagePointsList[matchedReferencePoints[index]].get_i(),referenceImagePointsList[matchedReferencePoints[index]].get_j());
145  currentPoint.set_ij(currentImagePointsList[index].get_i(), currentImagePointsList[index].get_j());
146  };
147 
168  inline unsigned int getIndexInAllReferencePointList ( const unsigned int indexInMatchedPointList ) {
169  if (indexInMatchedPointList >= matchedReferencePoints.size())
170  {
171  vpTRACE("Index of the matched reference point out of range");
172  throw(vpException(vpException::fatalError,"Index of the matched reference point out of range"));
173  }
174  return matchedReferencePoints[indexInMatchedPointList];
175  }
176 
182  inline unsigned int getReferencePointNumber() const {return (unsigned int)referenceImagePointsList.size();};
183 
189  inline unsigned int getMatchedPointNumber() const {return (unsigned int)matchedReferencePoints.size();};
190 
198  const std::vector<vpImagePoint>& getReferenceImagePointsList() const {return referenceImagePointsList;}
199 
207  const std::vector<vpImagePoint>& getCurrentImagePointsList() const {return currentImagePointsList;}
208 
218  const std::vector<unsigned int>& getMatchedReferencePoints() const {return matchedReferencePoints;}
219 
220  private:
221  virtual void init()=0;
222 
223  protected:
227  std::vector<vpImagePoint> referenceImagePointsList;
228 
233  std::vector<vpImagePoint> currentImagePointsList;
234 
241  std::vector<unsigned int> matchedReferencePoints;
242 
245 };
246 
247 #endif
248 
249 /*
250  * Local variables:
251  * c-basic-offset: 2
252  * End:
253  */
254 
class that defines what is a Keypoint. This class provides all the basic elements to implement classe...
unsigned int getIndexInAllReferencePointList(const unsigned int indexInMatchedPointList)
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
error that can be emited by ViSP classes.
Definition: vpException.h:73
void getMatchedPoints(const unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint)
static const vpColor green
Definition: vpColor.h:166
#define vpTRACE
Definition: vpDebug.h:414
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:82
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:88
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:185
unsigned int getReferencePointNumber() const