39#include <visp3/core/vpConfig.h>
41#if defined(VISP_HAVE_OPENCV) && (defined(HAVE_OPENCV_FEATURES2D) || defined(HAVE_OPENCV_FEATURES))
46#include <visp3/core/vpConvert.h>
56 vpImagePoint vpConvert::keyPointToVpImagePoint(
const cv::KeyPoint &keypoint)
58 return vpImagePoint(keypoint.pt.y, keypoint.pt.x);
67vpImagePoint vpConvert::point2fToVpImagePoint(
const cv::Point2f &point) {
return vpImagePoint(point.y, point.x); }
75vpImagePoint vpConvert::point2dToVpImagePoint(
const cv::Point2d &point) {
return vpImagePoint(point.y, point.x); }
83vpPoint vpConvert::point3fToVpObjectPoint(
const cv::Point3f &point3f)
99vpPoint vpConvert::point3fToVpCamPoint(
const cv::Point3f &point3f)
115vpPoint vpConvert::point3dToVpObjectPoint(
const cv::Point3d &point3d)
131vpPoint vpConvert::point3dToVpCamPoint(
const cv::Point3d &point3d)
147cv::Point2f vpConvert::vpImagePointToPoint2f(
const vpImagePoint &point)
149 return cv::Point2f(
static_cast<float>(point.
get_u()),
static_cast<float>(point.
get_v()));
158cv::Point2d vpConvert::vpImagePointToPoint2d(
const vpImagePoint &point)
160 return cv::Point2d(point.
get_u(), point.
get_v());
171cv::Point3f vpConvert::vpCamPointToPoint3f(
const vpPoint &point)
173 return cv::Point3f(
static_cast<float>(point.
get_X()),
static_cast<float>(point.
get_Y()),
static_cast<float>(point.
get_Z()));
184cv::Point3d vpConvert::vpCamPointToPoint3d(
const vpPoint &point)
196cv::Point3f vpConvert::vpObjectPointToPoint3f(
const vpPoint &point)
198 return cv::Point3f(
static_cast<float>(point.
get_oX()),
static_cast<float>(point.
get_oY()),
static_cast<float>(point.
get_oZ()));
208cv::Point3d vpConvert::vpObjectPointToPoint3d(
const vpPoint &point)
219int vpConvert::dMatchToTrainIndex(
const cv::DMatch &match) {
return match.trainIdx; }
252 to = point3fToVpCamPoint(from);
255 to = point3fToVpObjectPoint(from);
269 to = point3dToVpCamPoint(from);
272 to = point3dToVpObjectPoint(from);
283 to.resize(from.size());
284 std::transform(from.begin(), from.end(), to.begin(), keyPointToVpImagePoint);
294 to.resize(from.size());
295 std::transform(from.begin(), from.end(), to.begin(), point2fToVpImagePoint);
305 to.resize(from.size());
306 std::transform(from.begin(), from.end(), to.begin(), point2dToVpImagePoint);
318 to.resize(from.size());
320 std::transform(from.begin(), from.end(), to.begin(), point3fToVpCamPoint);
323 std::transform(from.begin(), from.end(), to.begin(), point3fToVpObjectPoint);
336 to.resize(from.size());
338 std::transform(from.begin(), from.end(), to.begin(), point3dToVpCamPoint);
341 std::transform(from.begin(), from.end(), to.begin(), point3dToVpObjectPoint);
357 to.resize(from.size());
358 std::transform(from.begin(), from.end(), to.begin(), dMatchToTrainIndex);
385 to = vpCamPointToPoint3f(from);
388 to = vpObjectPointToPoint3f(from);
402 to = vpCamPointToPoint3d(from);
405 to = vpObjectPointToPoint3d(from);
416 to.resize(from.size());
417 std::transform(from.begin(), from.end(), to.begin(), vpImagePointToPoint2f);
427 to.resize(from.size());
428 std::transform(from.begin(), from.end(), to.begin(), vpImagePointToPoint2d);
440 to.resize(from.size());
442 std::transform(from.begin(), from.end(), to.begin(), vpCamPointToPoint3f);
445 std::transform(from.begin(), from.end(), to.begin(), vpObjectPointToPoint3f);
458 to.resize(from.size());
460 std::transform(from.begin(), from.end(), to.begin(), vpCamPointToPoint3d);
463 std::transform(from.begin(), from.end(), to.begin(), vpObjectPointToPoint3d);
467#elif !defined(VISP_BUILD_SHARED_LIBS)
469void dummy_vpConvert() { }
static void convertFromOpenCV(const cv::KeyPoint &from, vpImagePoint &to)
static void convertToOpenCV(const vpImagePoint &from, cv::Point2f &to)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
double get_oX() const
Get the point oX coordinate in the object frame.
void set_W(double cW)
Set the point cW coordinate in the camera frame.
void set_oW(double oW)
Set the point oW coordinate in the object frame.
double get_Y() const
Get the point cY coordinate in the camera frame.
double get_oZ() const
Get the point oZ coordinate in the object frame.
void set_oY(double oY)
Set the point oY coordinate in the object frame.
void set_X(double cX)
Set the point cX coordinate in the camera frame.
void set_Y(double cY)
Set the point cY coordinate in the camera frame.
double get_Z() const
Get the point cZ coordinate in the camera frame.
void set_oZ(double oZ)
Set the point oZ coordinate in the object frame.
void set_Z(double cZ)
Set the point cZ coordinate in the camera frame.
void set_oX(double oX)
Set the point oX coordinate in the object frame.
double get_oY() const
Get the point oY coordinate in the object frame.
double get_X() const
Get the point cX coordinate in the camera frame.