Visual Servoing Platform  version 3.6.1 under development (2025-01-26)
vpConvert.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  * Directory management.
32  */
33 
39 #ifndef VP_CONVERT_H
40 #define VP_CONVERT_H
41 
42 #include <visp3/core/vpConfig.h>
43 
44 #if defined(VISP_HAVE_OPENCV) && (defined(HAVE_OPENCV_FEATURES2D) || defined(HAVE_OPENCV_FEATURES))
45 
46 #if defined(HAVE_OPENCV_FEATURES2D)
47 #include <opencv2/features2d/features2d.hpp>
48 #elif defined(HAVE_OPENCV_FEATURES)
49 #include <opencv2/features.hpp>
50 #endif
51 
52 #include <visp3/core/vpImagePoint.h>
53 #include <visp3/core/vpPoint.h>
54 
55 BEGIN_VISP_NAMESPACE
61 class VISP_EXPORT vpConvert
62 {
63 public:
64  static void convertFromOpenCV(const cv::KeyPoint &from, vpImagePoint &to);
65  static void convertFromOpenCV(const cv::Point2f &from, vpImagePoint &to);
66  static void convertFromOpenCV(const cv::Point2d &from, vpImagePoint &to);
67  static void convertFromOpenCV(const cv::Point3f &from, vpPoint &to, bool cameraFrame = false);
68  static void convertFromOpenCV(const cv::Point3d &from, vpPoint &to, bool cameraFrame = false);
69 
70  static void convertFromOpenCV(const std::vector<cv::KeyPoint> &from, std::vector<vpImagePoint> &to);
71  static void convertFromOpenCV(const std::vector<cv::Point2f> &from, std::vector<vpImagePoint> &to);
72  static void convertFromOpenCV(const std::vector<cv::Point2d> &from, std::vector<vpImagePoint> &to);
73  static void convertFromOpenCV(const std::vector<cv::Point3f> &from, std::vector<vpPoint> &to,
74  bool cameraFrame = false);
75  static void convertFromOpenCV(const std::vector<cv::Point3d> &from, std::vector<vpPoint> &to,
76  bool cameraFrame = false);
77  static void convertFromOpenCV(const std::vector<cv::DMatch> &from, std::vector<unsigned int> &to);
78 
79  static void convertToOpenCV(const vpImagePoint &from, cv::Point2f &to);
80  static void convertToOpenCV(const vpImagePoint &from, cv::Point2d &to);
81  static void convertToOpenCV(const vpPoint &from, cv::Point3f &to, bool cameraFrame = false);
82  static void convertToOpenCV(const vpPoint &from, cv::Point3d &to, bool cameraFrame = false);
83 
84  static void convertToOpenCV(const std::vector<vpImagePoint> &from, std::vector<cv::Point2f> &to);
85  static void convertToOpenCV(const std::vector<vpImagePoint> &from, std::vector<cv::Point2d> &to);
86  static void convertToOpenCV(const std::vector<vpPoint> &from, std::vector<cv::Point3f> &to, bool cameraFrame = false);
87  static void convertToOpenCV(const std::vector<vpPoint> &from, std::vector<cv::Point3d> &to, bool cameraFrame = false);
88 
89 private:
90  static vpImagePoint keyPointToVpImagePoint(const cv::KeyPoint &keypoint);
91  static vpImagePoint point2fToVpImagePoint(const cv::Point2f &point);
92  static vpImagePoint point2dToVpImagePoint(const cv::Point2d &point);
93  static vpPoint point3fToVpObjectPoint(const cv::Point3f &point3f);
94  static vpPoint point3dToVpObjectPoint(const cv::Point3d &point3d);
95  static vpPoint point3fToVpCamPoint(const cv::Point3f &point3f);
96  static vpPoint point3dToVpCamPoint(const cv::Point3d &point3d);
97  static int dMatchToTrainIndex(const cv::DMatch &match);
98 
99  static cv::Point2f vpImagePointToPoint2f(const vpImagePoint &point);
100  static cv::Point2d vpImagePointToPoint2d(const vpImagePoint &point);
101  static cv::Point3f vpCamPointToPoint3f(const vpPoint &point);
102  static cv::Point3d vpCamPointToPoint3d(const vpPoint &point);
103  static cv::Point3f vpObjectPointToPoint3f(const vpPoint &point);
104  static cv::Point3d vpObjectPointToPoint3d(const vpPoint &point);
105 
106 };
107 END_VISP_NAMESPACE
108 #endif
109 #endif
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:82
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:79