Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpBasicKeyPoint.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 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 VP_BASIC_KEYPOINT_H
35#define VP_BASIC_KEYPOINT_H
36
41
42#include <visp3/core/vpConfig.h>
43#include <visp3/core/vpDebug.h>
44#include <visp3/core/vpColor.h>
45#include <visp3/core/vpImage.h>
46#include <visp3/core/vpImagePoint.h>
47#include <visp3/core/vpRect.h>
48
49#include <vector>
50
60class VISP_EXPORT vpBasicKeyPoint
61{
62public:
69
73 virtual ~vpBasicKeyPoint();
74
78 virtual unsigned int buildReference(const vpImage<unsigned char> &I) = 0;
79
83 virtual unsigned int buildReference(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int height,
84 unsigned int width) = 0;
85
89 virtual unsigned int buildReference(const vpImage<unsigned char> &I, const vpRect &rectangle) = 0;
90
94 virtual unsigned int matchPoint(const vpImage<unsigned char> &I) = 0;
95
99 virtual unsigned int matchPoint(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int height,
100 unsigned int width) = 0;
101
105 virtual unsigned int matchPoint(const vpImage<unsigned char> &I, const vpRect &rectangle) = 0;
106
110 virtual void display(const vpImage<unsigned char> &Iref, const vpImage<unsigned char> &Icurrent, unsigned int size = 3) = 0;
111
115 virtual void display(const vpImage<unsigned char> &Icurrent, unsigned int size = 3, const vpColor &color = vpColor::green) = 0;
116
122 bool referenceBuilt() const { return m_reference_computed; }
123
131
141 inline void getReferencePoint(unsigned int index, vpImagePoint &referencePoint)
142 {
143 if (index >= m_referenceImagePointsList.size()) {
144 vpTRACE("Index of the reference point out of range");
145 throw(vpException(vpException::fatalError, "Index of the reference point out of range"));
146 }
147
148 referencePoint.set_ij(m_referenceImagePointsList[index].get_i(), m_referenceImagePointsList[index].get_j());
149 }
150
162 inline void getMatchedPoints(unsigned int index, vpImagePoint &referencePoint, vpImagePoint &currentPoint)
163 {
164 if (index >= m_matchedReferencePoints.size()) {
165 vpTRACE("Index of the matched points out of range");
166 throw(vpException(vpException::fatalError, "Index of the matched points out of range"));
167 }
168 referencePoint.set_ij(m_referenceImagePointsList[m_matchedReferencePoints[index]].get_i(),
170 currentPoint.set_ij(m_currentImagePointsList[index].get_i(), m_currentImagePointsList[index].get_j());
171 }
172
196 inline unsigned int getIndexInAllReferencePointList(unsigned int indexInMatchedPointList)
197 {
198 if (indexInMatchedPointList >= m_matchedReferencePoints.size()) {
199 vpTRACE("Index of the matched reference point out of range");
200 throw(vpException(vpException::fatalError, "Index of the matched reference point out of range"));
201 }
202 return m_matchedReferencePoints[indexInMatchedPointList];
203 }
204
210 inline unsigned int getReferencePointNumber() const { return static_cast<unsigned int>(m_referenceImagePointsList.size()); }
211
217 inline unsigned int getMatchedPointNumber() const { return static_cast<unsigned int>(m_matchedReferencePoints.size()); }
218
226 const std::vector<vpImagePoint> &getReferenceImagePointsList() const { return m_referenceImagePointsList; }
227
235 const std::vector<vpImagePoint> &getCurrentImagePointsList() const { return m_currentImagePointsList; }
236
246 const std::vector<unsigned int> &getMatchedReferencePoints() const { return m_matchedReferencePoints; }
247
248protected:
252 std::vector<vpImagePoint> m_referenceImagePointsList;
253
258 std::vector<vpImagePoint> m_currentImagePointsList;
259
268 std::vector<unsigned int> m_matchedReferencePoints;
269
274
275private:
276 virtual void init() = 0;
277};
278END_VISP_NAMESPACE
279#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
unsigned int getMatchedPointNumber() const
virtual unsigned int matchPoint(const vpImage< unsigned char > &I, const vpRect &rectangle)=0
const std::vector< vpImagePoint > & getReferenceImagePointsList() const
std::vector< unsigned int > m_matchedReferencePoints
void getReferencePoint(unsigned int index, vpImagePoint &referencePoint)
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 > m_currentImagePointsList
std::vector< vpImagePoint > m_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
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:157
static const vpColor green
Definition vpColor.h:201
error that can be emitted by ViSP classes.
Definition vpException.h:60
@ fatalError
Fatal error.
Definition vpException.h:72
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:131
Defines a rectangle in the plane.
Definition vpRect.h:79
#define vpTRACE
Definition vpDebug.h:450