Visual Servoing Platform  version 3.4.1 under development (2021-12-05)
vpConvert.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  * Directory management.
33  *
34  * Authors:
35  * Fabien Spindler
36  * Souriya Trinh
37  *
38  *****************************************************************************/
39 
40 #ifndef _vpConvert_h_
41 #define _vpConvert_h_
42 
48 #include <visp3/core/vpConfig.h>
49 
50 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
51 #include <opencv2/core/core.hpp>
52 #include <opencv2/features2d/features2d.hpp>
53 #endif
54 
55 #include <visp3/core/vpImagePoint.h>
56 #include <visp3/core/vpPoint.h>
57 
63 class VISP_EXPORT vpConvert
64 {
65 
66 public:
67 #if (VISP_HAVE_OPENCV_VERSION >= 0x020101)
68  static void convertFromOpenCV(const cv::KeyPoint &from, vpImagePoint &to);
69  static void convertFromOpenCV(const cv::Point2f &from, vpImagePoint &to);
70  static void convertFromOpenCV(const cv::Point2d &from, vpImagePoint &to);
71  static void convertFromOpenCV(const cv::Point3f &from, vpPoint &to, bool cameraFrame = false);
72  static void convertFromOpenCV(const cv::Point3d &from, vpPoint &to, bool cameraFrame = false);
73 
74  static void convertFromOpenCV(const std::vector<cv::KeyPoint> &from, std::vector<vpImagePoint> &to);
75  static void convertFromOpenCV(const std::vector<cv::Point2f> &from, std::vector<vpImagePoint> &to);
76  static void convertFromOpenCV(const std::vector<cv::Point2d> &from, std::vector<vpImagePoint> &to);
77  static void convertFromOpenCV(const std::vector<cv::Point3f> &from, std::vector<vpPoint> &to,
78  bool cameraFrame = false);
79  static void convertFromOpenCV(const std::vector<cv::Point3d> &from, std::vector<vpPoint> &to,
80  bool cameraFrame = false);
81  static void convertFromOpenCV(const std::vector<cv::DMatch> &from, std::vector<unsigned int> &to);
82 
83  static void convertToOpenCV(const vpImagePoint &from, cv::Point2f &to);
84  static void convertToOpenCV(const vpImagePoint &from, cv::Point2d &to);
85  static void convertToOpenCV(const vpPoint &from, cv::Point3f &to, bool cameraFrame = false);
86  static void convertToOpenCV(const vpPoint &from, cv::Point3d &to, bool cameraFrame = false);
87 
88  static void convertToOpenCV(const std::vector<vpImagePoint> &from, std::vector<cv::Point2f> &to);
89  static void convertToOpenCV(const std::vector<vpImagePoint> &from, std::vector<cv::Point2d> &to);
90  static void convertToOpenCV(const std::vector<vpPoint> &from, std::vector<cv::Point3f> &to,
91  bool cameraFrame = false);
92  static void convertToOpenCV(const std::vector<vpPoint> &from, std::vector<cv::Point3d> &to,
93  bool cameraFrame = false);
94 
95 private:
96  static vpImagePoint keyPointToVpImagePoint(const cv::KeyPoint &keypoint);
97  static vpImagePoint point2fToVpImagePoint(const cv::Point2f &point);
98  static vpImagePoint point2dToVpImagePoint(const cv::Point2d &point);
99  static vpPoint point3fToVpObjectPoint(const cv::Point3f &point3f);
100  static vpPoint point3dToVpObjectPoint(const cv::Point3d &point3d);
101  static vpPoint point3fToVpCamPoint(const cv::Point3f &point3f);
102  static vpPoint point3dToVpCamPoint(const cv::Point3d &point3d);
103  static int dMatchToTrainIndex(const cv::DMatch &match);
104 
105  static cv::Point2f vpImagePointToPoint2f(const vpImagePoint &point);
106  static cv::Point2d vpImagePointToPoint2d(const vpImagePoint &point);
107  static cv::Point3f vpCamPointToPoint3f(const vpPoint &point);
108  static cv::Point3d vpCamPointToPoint3d(const vpPoint &point);
109  static cv::Point3f vpObjectPointToPoint3f(const vpPoint &point);
110  static cv::Point3d vpObjectPointToPoint3d(const vpPoint &point);
111 
112 #endif
113 };
114 
115 #endif
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:81
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:87