conversion.hh
Go to the documentation of this file.
1 #ifndef VISP_TRACKER_CONVERSION_HH
2 # define VISP_TRACKER_CONVERSION_HH
3 # include <boost/optional.hpp>
4 
5 # include <ros/ros.h>
6 
7 # include <geometry_msgs/Transform.h>
8 # include <sensor_msgs/Image.h>
9 # include <sensor_msgs/CameraInfo.h>
10 # include <tf/transform_datatypes.h>
11 
12 # include <visp_tracker/Init.h>
13 
14 # include <visp3/core/vpConfig.h>
15 # include <visp3/mbt/vpMbGenericTracker.h>
16 
17 # include <visp3/core/vpHomogeneousMatrix.h>
18 # include <visp3/core/vpCameraParameters.h>
19 # include <visp3/me/vpMe.h>
20 # include <visp3/klt/vpKltOpencv.h>
21 
32 void rosImageToVisp(vpImage<unsigned char>& dst,
33  const sensor_msgs::Image::ConstPtr& src);
34 
45 void vispImageToRos(sensor_msgs::Image& dst,
46  const vpImage<unsigned char>& src);
47 
48 std::string convertVpMbTrackerToRosMessage(const vpMbGenericTracker &tracker);
49 
50 std::string convertVpMeToRosMessage(const vpMbGenericTracker &tracker, const vpMe& moving_edge);
51 
52 std::string convertVpKltOpencvToRosMessage(const vpMbGenericTracker &tracker, const vpKltOpencv& klt);
53 
54 void vpHomogeneousMatrixToTransform(geometry_msgs::Transform& dst,
55  const vpHomogeneousMatrix& src);
56 
57 void transformToVpHomogeneousMatrix(vpHomogeneousMatrix& dst,
58  const geometry_msgs::Transform& src);
59 
60 void transformToVpHomogeneousMatrix(vpHomogeneousMatrix& dst,
61  const tf::Transform& src);
62 
63 void transformToVpHomogeneousMatrix(vpHomogeneousMatrix& dst,
64  const geometry_msgs::Pose& src);
65 
66 void convertVpMbTrackerToInitRequest(const vpMbGenericTracker &tracker,
67  visp_tracker::Init& srv);
68 
69 void convertInitRequestToVpMbTracker(const visp_tracker::Init::Request& req,
70  vpMbGenericTracker &tracker);
71 
72 void convertVpMeToInitRequest(const vpMe& moving_edge,
73  const vpMbGenericTracker &tracker,
74  visp_tracker::Init& srv);
75 
76 void convertInitRequestToVpMe(const visp_tracker::Init::Request& req,
77  vpMbGenericTracker &tracker,
78  vpMe& moving_edge);
79 
80 void convertVpKltOpencvToInitRequest(const vpKltOpencv& klt,
81  const vpMbGenericTracker &tracker,
82  visp_tracker::Init& srv);
83 
84 void convertInitRequestToVpKltOpencv(const visp_tracker::Init::Request& req,
85  vpMbGenericTracker &tracker,
86  vpKltOpencv& klt);
87 
88 void initializeVpCameraFromCameraInfo(vpCameraParameters& cam,
89  sensor_msgs::CameraInfoConstPtr info);
90 
91 // Dynamic reconfigure template functions
92 template<class ConfigType>
93 void convertModelBasedSettingsConfigToVpMbTracker(const ConfigType& config,
94  vpMbGenericTracker &tracker)
95 {
96  tracker.setAngleAppear(vpMath::rad(config.angle_appear));
97  tracker.setAngleDisappear(vpMath::rad(config.angle_disappear));
98 }
99 
100 template<class ConfigType>
101 void convertVpMbTrackerToModelBasedSettingsConfig(const vpMbGenericTracker &tracker,
102  ConfigType& config)
103 {
104  config.angle_appear = vpMath::deg(tracker.getAngleAppear());
105  config.angle_disappear = vpMath::deg(tracker.getAngleDisappear());
106 }
107 
108 template<class ConfigType>
109 void convertModelBasedSettingsConfigToVpMe(const ConfigType& config,
110  vpMe& moving_edge,
111  vpMbGenericTracker &tracker)
112 {
113  tracker.setGoodMovingEdgesRatioThreshold(config.first_threshold);
114  moving_edge.setThreshold( config.threshold );
115  moving_edge.setMaskSize( config.mask_size );
116  moving_edge.setRange( config.range );
117  moving_edge.setMu1( config.mu1 );
118  moving_edge.setMu2( config.mu2 );
119  moving_edge.setSampleStep( config.sample_step );
120  moving_edge.setStrip( config.strip );
121 
122  //FIXME: not sure if this is needed.
123  moving_edge.initMask();
124  //Reset the tracker and the node state.
125  tracker.setMovingEdge(moving_edge);
126 }
127 
128 template<class ConfigType>
129 void convertVpMeToModelBasedSettingsConfig(const vpMe& moving_edge,
130  const vpMbGenericTracker &tracker,
131  ConfigType& config)
132 {
133  config.first_threshold = tracker.getGoodMovingEdgesRatioThreshold();
134  config.threshold = moving_edge.getThreshold();
135  config.mask_size = moving_edge.getMaskSize();
136  config.range = moving_edge.getRange();
137  config.mu1 = moving_edge.getMu1();
138  config.mu2 = moving_edge.getMu2();
139  config.sample_step = moving_edge.getSampleStep();
140  config.strip = moving_edge.getStrip();
141 }
142 
143 template<class ConfigType>
144 void convertModelBasedSettingsConfigToVpKltOpencv(const ConfigType& config,
145  vpKltOpencv& klt,
146  vpMbGenericTracker &tracker)
147 {
148  klt.setMaxFeatures(config.max_features);
149  klt.setWindowSize(config.window_size);
150  klt.setQuality(config.quality);
151  klt.setMinDistance(config.min_distance);
152  klt.setHarrisFreeParameter(config.harris);
153  klt.setBlockSize(config.size_block);
154  klt.setPyramidLevels(config.pyramid_lvl);
155  tracker.setKltMaskBorder((unsigned)config.mask_border);
156 
157  tracker.setKltOpencv(klt);
158 }
159 
160 template<class ConfigType>
162  const vpMbGenericTracker &tracker,
163  ConfigType& config)
164 {
165  config.max_features = klt.getMaxFeatures();
166  config.window_size = klt.getWindowSize();
167  config.quality = klt.getQuality();
168  config.min_distance = klt.getMinDistance();
169  config.harris = klt.getHarrisFreeParameter();
170  config.size_block = klt.getBlockSize();
171  config.pyramid_lvl = klt.getPyramidLevels();
172  config.mask_border = tracker.getKltMaskBorder();
173 }
174 
175 #endif
void convertModelBasedSettingsConfigToVpKltOpencv(const ConfigType &config, vpKltOpencv &klt, vpMbGenericTracker &tracker)
Definition: conversion.hh:144
std::string convertVpMbTrackerToRosMessage(const vpMbGenericTracker &tracker)
Definition: conversion.cpp:81
void vpHomogeneousMatrixToTransform(geometry_msgs::Transform &dst, const vpHomogeneousMatrix &src)
Definition: conversion.cpp:122
void convertVpMeToInitRequest(const vpMe &moving_edge, const vpMbGenericTracker &tracker, visp_tracker::Init &srv)
Definition: conversion.cpp:193
void convertInitRequestToVpMe(const visp_tracker::Init::Request &req, vpMbGenericTracker &tracker, vpMe &moving_edge)
Definition: conversion.cpp:207
void convertInitRequestToVpKltOpencv(const visp_tracker::Init::Request &req, vpMbGenericTracker &tracker, vpKltOpencv &klt)
Definition: conversion.cpp:240
void convertModelBasedSettingsConfigToVpMbTracker(const ConfigType &config, vpMbGenericTracker &tracker)
Definition: conversion.hh:93
void vispImageToRos(sensor_msgs::Image &dst, const vpImage< unsigned char > &src)
Convert a ViSP image into a ROS one.
Definition: conversion.cpp:67
void convertInitRequestToVpMbTracker(const visp_tracker::Init::Request &req, vpMbGenericTracker &tracker)
Definition: conversion.cpp:186
void initializeVpCameraFromCameraInfo(vpCameraParameters &cam, sensor_msgs::CameraInfoConstPtr info)
Definition: conversion.cpp:256
void transformToVpHomogeneousMatrix(vpHomogeneousMatrix &dst, const geometry_msgs::Transform &src)
Definition: conversion.cpp:138
void convertVpMbTrackerToInitRequest(const vpMbGenericTracker &tracker, visp_tracker::Init &srv)
Definition: conversion.cpp:179
void convertModelBasedSettingsConfigToVpMe(const ConfigType &config, vpMe &moving_edge, vpMbGenericTracker &tracker)
Definition: conversion.hh:109
void convertVpMeToModelBasedSettingsConfig(const vpMe &moving_edge, const vpMbGenericTracker &tracker, ConfigType &config)
Definition: conversion.hh:129
void rosImageToVisp(vpImage< unsigned char > &dst, const sensor_msgs::Image::ConstPtr &src)
Convert a ROS image into a ViSP one.
Definition: conversion.cpp:21
std::string convertVpMeToRosMessage(const vpMbGenericTracker &tracker, const vpMe &moving_edge)
Definition: conversion.cpp:90
void convertVpMbTrackerToModelBasedSettingsConfig(const vpMbGenericTracker &tracker, ConfigType &config)
Definition: conversion.hh:101
void convertVpKltOpencvToInitRequest(const vpKltOpencv &klt, const vpMbGenericTracker &tracker, visp_tracker::Init &srv)
Definition: conversion.cpp:226
void convertVpKltOpencvToModelBasedSettingsConfig(const vpKltOpencv &klt, const vpMbGenericTracker &tracker, ConfigType &config)
Definition: conversion.hh:161
std::string convertVpKltOpencvToRosMessage(const vpMbGenericTracker &tracker, const vpKltOpencv &klt)
Definition: conversion.cpp:106


visp_tracker
Author(s): Thomas Moulard
autogenerated on Sat Mar 13 2021 03:20:06