1 #ifndef VISP_TRACKER_CONVERSION_HH 2 # define VISP_TRACKER_CONVERSION_HH 3 # include <boost/optional.hpp> 7 # include <geometry_msgs/Transform.h> 8 # include <sensor_msgs/Image.h> 9 # include <sensor_msgs/CameraInfo.h> 12 # include <visp_tracker/Init.h> 14 #include <visp/vpConfig.h> 15 #if VISP_VERSION_INT < VP_VERSION_INT(2,10,0) 16 # define protected public 18 # include <visp/vpMbEdgeTracker.h> 19 # include <visp/vpMbKltTracker.h> 20 # include <visp/vpMbTracker.h> 21 #if VISP_VERSION_INT < VP_VERSION_INT(2,10,0) 25 # include <visp/vpHomogeneousMatrix.h> 26 # include <visp/vpCameraParameters.h> 27 # include <visp/vpMe.h> 28 # include <visp/vpKltOpencv.h> 41 const sensor_msgs::Image::ConstPtr& src);
54 const vpImage<unsigned char>& src);
63 const vpHomogeneousMatrix& src);
66 const geometry_msgs::Transform& src);
72 const geometry_msgs::Pose& src);
75 visp_tracker::Init& srv);
78 vpMbTracker* tracker);
81 const vpMbTracker* tracker,
82 visp_tracker::Init& srv);
89 const vpMbTracker* tracker,
90 visp_tracker::Init& srv);
97 sensor_msgs::CameraInfoConstPtr info);
100 template<
class ConfigType>
102 vpMbTracker* tracker)
104 #if VISP_VERSION_INT >= VP_VERSION_INT(2,10,0) 105 tracker->setAngleAppear(vpMath::rad(config.angle_appear));
106 tracker->setAngleDisappear(vpMath::rad(config.angle_disappear));
108 vpMbEdgeTracker* tracker_edge =
dynamic_cast<vpMbEdgeTracker*
>(tracker);
109 if (tracker_edge != NULL) {
110 ROS_INFO(
"Set param angle from edge");
111 tracker_edge->setAngleAppear(vpMath::rad(config.angle_appear));
112 tracker_edge->setAngleDisappear(vpMath::rad(config.angle_disappear));
115 vpMbKltTracker* tracker_klt =
dynamic_cast<vpMbKltTracker*
>(tracker);
116 if (tracker_klt != NULL) {
117 ROS_INFO(
"Set param angle from klt");
118 tracker_klt->setAngleAppear(vpMath::rad(config.angle_appear));
119 tracker_klt->setAngleDisappear(vpMath::rad(config.angle_disappear));
125 template<
class ConfigType>
129 #if VISP_VERSION_INT >= VP_VERSION_INT(2,10,0) 130 config.angle_appear = vpMath::deg(tracker->getAngleAppear());
131 config.angle_disappear = vpMath::deg(tracker->getAngleDisappear());
133 const vpMbEdgeTracker* tracker_edge =
dynamic_cast<const vpMbEdgeTracker*
>(tracker);
134 if (tracker_edge != NULL) {
135 ROS_INFO(
"Modif config param angle from edge");
136 config.angle_appear = vpMath::deg(tracker_edge->getAngleAppear());
137 config.angle_disappear = vpMath::deg(tracker_edge->getAngleDisappear());
140 const vpMbKltTracker* tracker_klt =
dynamic_cast<const vpMbKltTracker*
>(tracker);
141 if (tracker_klt != NULL) {
142 ROS_INFO(
"Modif config param angle from klt");
143 config.angle_appear = vpMath::deg(tracker_klt->getAngleAppear());
144 config.angle_disappear = vpMath::deg(tracker_klt->getAngleDisappear());
150 template<
class ConfigType>
153 vpMbTracker* tracker)
155 vpMbEdgeTracker* t =
dynamic_cast<vpMbEdgeTracker*
>(tracker);
158 #if VISP_VERSION_INT >= VP_VERSION_INT(2,10,0) 159 t->setGoodMovingEdgesRatioThreshold(config.first_threshold);
160 moving_edge.setThreshold( config.threshold );
161 moving_edge.setMaskSize( config.mask_size );
162 moving_edge.setRange( config.range );
163 moving_edge.setMu1( config.mu1 );
164 moving_edge.setMu2( config.mu2 );
165 moving_edge.setSampleStep( config.sample_step );
166 moving_edge.setStrip( config.strip );
168 t->setFirstThreshold(config.first_threshold);
169 moving_edge.threshold = config.threshold;
170 moving_edge.mask_size = config.mask_size;
171 moving_edge.range = config.range;
172 moving_edge.mu1 = config.mu1;
173 moving_edge.mu2 = config.mu2;
174 moving_edge.sample_step = config.sample_step;
175 moving_edge.strip = config.strip;
179 moving_edge.initMask();
181 t->setMovingEdge(moving_edge);
184 template<
class ConfigType>
186 const vpMbTracker* tracker,
189 const vpMbEdgeTracker* t =
dynamic_cast<const vpMbEdgeTracker*
>(tracker);
192 #if VISP_VERSION_INT >= VP_VERSION_INT(2,10,0) 193 config.first_threshold = t->getGoodMovingEdgesRatioThreshold();
194 config.threshold = moving_edge.getThreshold();
195 config.mask_size = moving_edge.getMaskSize();
196 config.range = moving_edge.getRange();
197 config.mu1 = moving_edge.getMu1();
198 config.mu2 = moving_edge.getMu2();
199 config.sample_step = moving_edge.getSampleStep();
200 config.strip = moving_edge.getStrip();
202 config.first_threshold = t->getFirstThreshold();
203 config.threshold = moving_edge.threshold;
204 config.mask_size = moving_edge.mask_size;
205 config.range = moving_edge.range;
206 config.mu1 = moving_edge.mu1;
207 config.mu2 = moving_edge.mu2;
208 config.sample_step = moving_edge.sample_step;
209 config.strip = moving_edge.strip;
213 template<
class ConfigType>
216 vpMbTracker* tracker)
218 vpMbKltTracker* t =
dynamic_cast<vpMbKltTracker*
>(tracker);
220 klt.setMaxFeatures(config.max_features);
221 klt.setWindowSize(config.window_size);
222 klt.setQuality(config.quality);
223 klt.setMinDistance(config.min_distance);
224 klt.setHarrisFreeParameter(config.harris);
225 klt.setBlockSize(config.size_block);
226 klt.setPyramidLevels(config.pyramid_lvl);
227 t->setMaskBorder((
unsigned)config.mask_border);
229 t->setKltOpencv(klt);
232 template<
class ConfigType>
234 const vpMbTracker* tracker,
237 const vpMbKltTracker* t =
dynamic_cast<const vpMbKltTracker*
>(tracker);
239 config.max_features = klt.getMaxFeatures();
240 config.window_size = klt.getWindowSize();
241 config.quality = klt.getQuality();
242 config.min_distance = klt.getMinDistance();
243 config.harris = klt.getHarrisFreeParameter();
244 config.size_block = klt.getBlockSize();
245 config.pyramid_lvl = klt.getPyramidLevels();
246 config.mask_border = t->getMaskBorder();
void convertInitRequestToVpMe(const visp_tracker::Init::Request &req, vpMbTracker *tracker, vpMe &moving_edge)
void vpHomogeneousMatrixToTransform(geometry_msgs::Transform &dst, const vpHomogeneousMatrix &src)
std::string convertVpMbTrackerToRosMessage(const vpMbTracker *tracker)
void convertVpMeToModelBasedSettingsConfig(const vpMe &moving_edge, const vpMbTracker *tracker, ConfigType &config)
void convertVpMbTrackerToInitRequest(const vpMbTracker *tracker, visp_tracker::Init &srv)
void vispImageToRos(sensor_msgs::Image &dst, const vpImage< unsigned char > &src)
Convert a ViSP image into a ROS one.
std::string convertVpMeToRosMessage(const vpMbTracker *tracker, const vpMe &moving_edge)
void convertVpKltOpencvToInitRequest(const vpKltOpencv &klt, const vpMbTracker *tracker, visp_tracker::Init &srv)
std::string convertVpKltOpencvToRosMessage(const vpMbTracker *tracker, const vpKltOpencv &klt)
void initializeVpCameraFromCameraInfo(vpCameraParameters &cam, sensor_msgs::CameraInfoConstPtr info)
void convertVpMbTrackerToModelBasedSettingsConfig(const vpMbTracker *tracker, ConfigType &config)
void transformToVpHomogeneousMatrix(vpHomogeneousMatrix &dst, const geometry_msgs::Transform &src)
void convertModelBasedSettingsConfigToVpMbTracker(const ConfigType &config, vpMbTracker *tracker)
void convertVpMeToInitRequest(const vpMe &moving_edge, const vpMbTracker *tracker, visp_tracker::Init &srv)
void rosImageToVisp(vpImage< unsigned char > &dst, const sensor_msgs::Image::ConstPtr &src)
Convert a ROS image into a ViSP one.
void convertVpKltOpencvToModelBasedSettingsConfig(const vpKltOpencv &klt, const vpMbTracker *tracker, ConfigType &config)
void convertModelBasedSettingsConfigToVpKltOpencv(const ConfigType &config, vpKltOpencv &klt, vpMbTracker *tracker)
void convertModelBasedSettingsConfigToVpMe(const ConfigType &config, vpMe &moving_edge, vpMbTracker *tracker)
void convertInitRequestToVpMbTracker(const visp_tracker::Init::Request &req, vpMbTracker *tracker)
void convertInitRequestToVpKltOpencv(const visp_tracker::Init::Request &req, vpMbTracker *tracker, vpKltOpencv &klt)