Visual Servoing Platform  version 3.4.0
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 
118  inline void getReferencePoint(unsigned int index, vpImagePoint &referencePoint)
119  {
120  if (index >= referenceImagePointsList.size()) {
121  vpTRACE("Index of the reference point out of range");
122  throw(vpException(vpException::fatalError, "Index of the reference point out of range"));
123  }
124 
125  referencePoint.set_ij(referenceImagePointsList[index].get_i(), referenceImagePointsList[index].get_j());
126  }
127 
139  inline void getMatchedPoints(unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint)
140  {
141  if (index >= matchedReferencePoints.size()) {
142  vpTRACE("Index of the matched points out of range");
143  throw(vpException(vpException::fatalError, "Index of the matched points out of range"));
144  }
145  referencePoint.set_ij(referenceImagePointsList[matchedReferencePoints[index]].get_i(),
146  referenceImagePointsList[matchedReferencePoints[index]].get_j());
147  currentPoint.set_ij(currentImagePointsList[index].get_i(), currentImagePointsList[index].get_j());
148  }
149 
174  inline unsigned int getIndexInAllReferencePointList(unsigned int indexInMatchedPointList)
175  {
176  if (indexInMatchedPointList >= matchedReferencePoints.size()) {
177  vpTRACE("Index of the matched reference point out of range");
178  throw(vpException(vpException::fatalError, "Index of the matched reference point out of range"));
179  }
180  return matchedReferencePoints[indexInMatchedPointList];
181  }
182 
188  inline unsigned int getReferencePointNumber() const { return (unsigned int)referenceImagePointsList.size(); };
189 
195  inline unsigned int getMatchedPointNumber() const { return (unsigned int)matchedReferencePoints.size(); };
196 
204  const std::vector<vpImagePoint> &getReferenceImagePointsList() const { return referenceImagePointsList; }
205 
213  const std::vector<vpImagePoint> &getCurrentImagePointsList() const { return currentImagePointsList; }
214 
224  const std::vector<unsigned int> &getMatchedReferencePoints() const { return matchedReferencePoints; }
225 
226 private:
227  virtual void init() = 0;
228 
229 protected:
233  std::vector<vpImagePoint> referenceImagePointsList;
234 
239  std::vector<vpImagePoint> currentImagePointsList;
240 
249  std::vector<unsigned int> matchedReferencePoints;
250 
253 };
254 
255 #endif
unsigned int getIndexInAllReferencePointList(unsigned int indexInMatchedPointList)
class that defines what is a Keypoint. This class provides all the basic elements to implement classe...
Class to define RGB colors available for display functionnalities.
Definition: vpColor.h:157
error that can be emited by ViSP classes.
Definition: vpException.h:71
static const vpColor green
Definition: vpColor.h:220
#define vpTRACE
Definition: vpDebug.h:416
void getMatchedPoints(unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint)
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
void set_ij(double ii, double jj)
Definition: vpImagePoint.h:188
const vpImagePoint * getAllPointsInReferenceImage()
std::vector< unsigned int > matchedReferencePoints
virtual ~vpBasicKeyPoint()
Defines a rectangle in the plane.
Definition: vpRect.h:79
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:87
void getReferencePoint(unsigned int index, vpImagePoint &referencePoint)
const std::vector< vpImagePoint > & getReferenceImagePointsList() const
const std::vector< unsigned int > & getMatchedReferencePoints() const
unsigned int getMatchedPointNumber() const
unsigned int getReferencePointNumber() const