Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpBasicKeyPoint.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 https://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
34#ifndef vpBasicKeyPoint_H
35#define vpBasicKeyPoint_H
36
42#include <visp3/core/vpColor.h>
43#include <visp3/core/vpImage.h>
44#include <visp3/core/vpImagePoint.h>
45#include <visp3/core/vpRect.h>
46
47#include <vector>
48
57class VISP_EXPORT vpBasicKeyPoint
58{
59public:
64 : referenceImagePointsList(), currentImagePointsList(), matchedReferencePoints(), _reference_computed(false)
65 { }
66
71 {
72 matchedReferencePoints.resize(0);
73 currentImagePointsList.resize(0);
74 referenceImagePointsList.resize(0);
75 }
76
80 virtual unsigned int buildReference(const vpImage<unsigned char> &I) = 0;
81
85 virtual unsigned int buildReference(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int height,
86 unsigned int width) = 0;
87
91 virtual unsigned int buildReference(const vpImage<unsigned char> &I, const vpRect &rectangle) = 0;
92
96 virtual unsigned int matchPoint(const vpImage<unsigned char> &I) = 0;
97
101 virtual unsigned int matchPoint(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int height,
102 unsigned int width) = 0;
103
107 virtual unsigned int matchPoint(const vpImage<unsigned char> &I, const vpRect &rectangle) = 0;
108
112 virtual void display(const vpImage<unsigned char> &Iref, const vpImage<unsigned char> &Icurrent,
113 unsigned int size = 3) = 0;
114
118 virtual void display(const vpImage<unsigned char> &Icurrent, unsigned int size = 3,
119 const vpColor &color = vpColor::green) = 0;
120
126 bool referenceBuilt() const { return _reference_computed; }
127
134 inline const vpImagePoint *getAllPointsInReferenceImage() { return &referenceImagePointsList[0]; }
135
145 inline void getReferencePoint(unsigned int index, vpImagePoint &referencePoint)
146 {
147 if (index >= referenceImagePointsList.size()) {
148 vpTRACE("Index of the reference point out of range");
149 throw(vpException(vpException::fatalError, "Index of the reference point out of range"));
150 }
151
152 referencePoint.set_ij(referenceImagePointsList[index].get_i(), referenceImagePointsList[index].get_j());
153 }
154
166 inline void getMatchedPoints(unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint)
167 {
168 if (index >= matchedReferencePoints.size()) {
169 vpTRACE("Index of the matched points out of range");
170 throw(vpException(vpException::fatalError, "Index of the matched points out of range"));
171 }
172 referencePoint.set_ij(referenceImagePointsList[matchedReferencePoints[index]].get_i(),
173 referenceImagePointsList[matchedReferencePoints[index]].get_j());
174 currentPoint.set_ij(currentImagePointsList[index].get_i(), currentImagePointsList[index].get_j());
175 }
176
200 inline unsigned int getIndexInAllReferencePointList(unsigned int indexInMatchedPointList)
201 {
202 if (indexInMatchedPointList >= matchedReferencePoints.size()) {
203 vpTRACE("Index of the matched reference point out of range");
204 throw(vpException(vpException::fatalError, "Index of the matched reference point out of range"));
205 }
206 return matchedReferencePoints[indexInMatchedPointList];
207 }
208
214 inline unsigned int getReferencePointNumber() const { return (unsigned int)referenceImagePointsList.size(); };
215
221 inline unsigned int getMatchedPointNumber() const { return (unsigned int)matchedReferencePoints.size(); };
222
230 const std::vector<vpImagePoint> &getReferenceImagePointsList() const { return referenceImagePointsList; }
231
239 const std::vector<vpImagePoint> &getCurrentImagePointsList() const { return currentImagePointsList; }
240
250 const std::vector<unsigned int> &getMatchedReferencePoints() const { return matchedReferencePoints; }
251
252private:
253 virtual void init() = 0;
254
255protected:
259 std::vector<vpImagePoint> referenceImagePointsList;
260
265 std::vector<vpImagePoint> currentImagePointsList;
266
275 std::vector<unsigned int> matchedReferencePoints;
276
281};
282
283#endif
class that defines what is a keypoint. This class provides all the basic elements to implement classe...
bool referenceBuilt() const
virtual unsigned int buildReference(const vpImage< unsigned char > &I)=0
std::vector< vpImagePoint > currentImagePointsList
unsigned int getMatchedPointNumber() const
virtual unsigned int matchPoint(const vpImage< unsigned char > &I, const vpRect &rectangle)=0
const std::vector< vpImagePoint > & getReferenceImagePointsList() const
void getReferencePoint(unsigned int index, vpImagePoint &referencePoint)
std::vector< unsigned int > matchedReferencePoints
void getMatchedPoints(unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint)
virtual unsigned int matchPoint(const vpImage< unsigned char > &I, const vpImagePoint &iP, unsigned int height, unsigned int width)=0
std::vector< vpImagePoint > referenceImagePointsList
virtual unsigned int buildReference(const vpImage< unsigned char > &I, const vpImagePoint &iP, unsigned int height, unsigned int width)=0
virtual void display(const vpImage< unsigned char > &Icurrent, unsigned int size=3, const vpColor &color=vpColor::green)=0
virtual unsigned int buildReference(const vpImage< unsigned char > &I, const vpRect &rectangle)=0
virtual ~vpBasicKeyPoint()
const std::vector< vpImagePoint > & getCurrentImagePointsList() const
unsigned int getIndexInAllReferencePointList(unsigned int indexInMatchedPointList)
virtual unsigned int matchPoint(const vpImage< unsigned char > &I)=0
unsigned int getReferencePointNumber() const
const std::vector< unsigned int > & getMatchedReferencePoints() const
const vpImagePoint * getAllPointsInReferenceImage()
virtual void display(const vpImage< unsigned char > &Iref, const vpImage< unsigned char > &Icurrent, unsigned int size=3)=0
Class to define RGB colors available for display functionalities.
Definition vpColor.h:152
static const vpColor green
Definition vpColor.h:214
error that can be emitted by ViSP classes.
Definition vpException.h:59
@ fatalError
Fatal error.
Definition vpException.h:84
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void set_ij(double ii, double jj)
Definition of the vpImage class member functions.
Definition vpImage.h:135
Defines a rectangle in the plane.
Definition vpRect.h:76
#define vpTRACE
Definition vpDebug.h:411