Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
vpBasicKeyPoint.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Key point used in matching algorithm.
33  *
34  * Authors:
35  * Nicolas Melchior
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 
62 class VISP_EXPORT vpBasicKeyPoint
63 {
64 public:
66 
67  virtual ~vpBasicKeyPoint()
68  {
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, const vpImagePoint &iP,
77  unsigned int height, unsigned int width) = 0;
78 
79  virtual unsigned int buildReference(const vpImage<unsigned char> &I, const vpRect &rectangle) = 0;
80 
81  virtual unsigned int matchPoint(const vpImage<unsigned char> &I) = 0;
82 
83  virtual unsigned int matchPoint(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int height,
84  unsigned int width) = 0;
85 
86  virtual unsigned int matchPoint(const vpImage<unsigned char> &I, const vpRect &rectangle) = 0;
87 
88  virtual void display(const vpImage<unsigned char> &Iref, const vpImage<unsigned char> &Icurrent,
89  unsigned int size = 3) = 0;
90 
91  virtual void display(const vpImage<unsigned char> &Icurrent, unsigned int size = 3,
92  const vpColor &color = vpColor::green) = 0;
93 
99  bool referenceBuilt() const { return _reference_computed; }
100 
107  inline const vpImagePoint *getAllPointsInReferenceImage() { return &referenceImagePointsList[0]; };
108 
117  inline void getReferencePoint(unsigned int index, vpImagePoint &referencePoint)
118  {
119  if (index >= referenceImagePointsList.size()) {
120  vpTRACE("Index of the reference point out of range");
121  throw(vpException(vpException::fatalError, "Index of the reference point out of range"));
122  }
123 
124  referencePoint.set_ij(referenceImagePointsList[index].get_i(), referenceImagePointsList[index].get_j());
125  }
126 
138  inline void getMatchedPoints(unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint)
139  {
140  if (index >= matchedReferencePoints.size()) {
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(),
145  referenceImagePointsList[matchedReferencePoints[index]].get_j());
146  currentPoint.set_ij(currentImagePointsList[index].get_i(), currentImagePointsList[index].get_j());
147  };
148 
173  inline unsigned int getIndexInAllReferencePointList(unsigned int indexInMatchedPointList)
174  {
175  if (indexInMatchedPointList >= matchedReferencePoints.size()) {
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 
248  std::vector<unsigned int> matchedReferencePoints;
249 
252 };
253 
254 #endif
255 
256 /*
257  * Local variables:
258  * c-basic-offset: 2
259  * End:
260  */
unsigned int getIndexInAllReferencePointList(unsigned int indexInMatchedPointList)
class that defines what is a Keypoint. This class provides all the basic elements to implement classe...
unsigned int getMatchedPointNumber() const
const std::vector< vpImagePoint > & getCurrentImagePointsList() const
Class to define colors available for display functionnalities.
Definition: vpColor.h:119
error that can be emited by ViSP classes.
Definition: vpException.h:71
unsigned int getReferencePointNumber() const
static const vpColor green
Definition: vpColor.h:182
const std::vector< unsigned int > & getMatchedReferencePoints() const
#define vpTRACE
Definition: vpDebug.h:416
void getMatchedPoints(unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint)
bool _reference_computed
flag to indicate if the reference has been built.
std::vector< vpImagePoint > referenceImagePointsList
void set_ij(double ii, double jj)
Definition: vpImagePoint.h:189
const vpImagePoint * getAllPointsInReferenceImage()
std::vector< unsigned int > matchedReferencePoints
virtual ~vpBasicKeyPoint()
Defines a rectangle in the plane.
Definition: vpRect.h:78
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
bool referenceBuilt() const
void getReferencePoint(unsigned int index, vpImagePoint &referencePoint)
const std::vector< vpImagePoint > & getReferenceImagePointsList() const