2 #include <boost/bind.hpp> 4 #include <sensor_msgs/Image.h> 5 #include <visp/vpImage.h> 7 #include <visp_tracker/Init.h> 13 # include <visp/vpMbEdgeTracker.h> 14 # include <visp/vpMbKltTracker.h> 17 const sensor_msgs::Image::ConstPtr& msg,
18 const sensor_msgs::CameraInfoConstPtr& info)
24 catch(std::exception& e)
31 std_msgs::Header& header,
32 sensor_msgs::CameraInfoConstPtr& info,
33 const sensor_msgs::Image::ConstPtr& msg,
34 const sensor_msgs::CameraInfoConstPtr& infoConst)
49 std_msgs::Header& header,
50 sensor_msgs::CameraInfoConstPtr& info)
54 boost::ref(image), boost::ref(header), boost::ref(info), _1, _2);
58 vpImage<unsigned char>& I,
60 vpKltOpencv& kltTracker,
61 boost::recursive_mutex& mutex,
62 visp_tracker::ModelBasedSettingsConfig& config,
68 ROS_INFO(
"Reconfigure Model Based Hybrid Tracker request received.");
70 convertModelBasedSettingsConfigToVpMbTracker<visp_tracker::ModelBasedSettingsConfig>(config, tracker);
72 convertModelBasedSettingsConfigToVpMe<visp_tracker::ModelBasedSettingsConfig>(config, moving_edge, tracker);
75 convertModelBasedSettingsConfigToVpKltOpencv<visp_tracker::ModelBasedSettingsConfig>(config, kltTracker, tracker);
77 vpHomogeneousMatrix cMo;
78 tracker->getPose(cMo);
80 #if VISP_VERSION_INT < VP_VERSION_INT(2,10,0) 83 vpMbKltTracker* tracker_klt =
dynamic_cast<vpMbKltTracker*
>(tracker);
84 if (tracker_klt != NULL)
85 tracker_klt->firstTrack =
true;
89 if (I.getHeight() != 0 && I.getWidth() != 0) {
90 #if VISP_VERSION_INT < VP_VERSION_INT(3,0,0) 94 tracker->setPose(I, cMo);
96 tracker->initFromPose(I, cMo);
108 vpImage<unsigned char>& I,
110 boost::recursive_mutex& mutex,
111 visp_tracker::ModelBasedSettingsEdgeConfig& config,
118 ROS_INFO(
"Reconfigure Model Based Edge Tracker request received.");
120 convertModelBasedSettingsConfigToVpMbTracker<visp_tracker::ModelBasedSettingsEdgeConfig>(config, tracker);
121 convertModelBasedSettingsConfigToVpMe<visp_tracker::ModelBasedSettingsEdgeConfig>(config, moving_edge, tracker);
125 if (I.getHeight() != 0 && I.getWidth() != 0) {
126 vpHomogeneousMatrix cMo;
127 tracker->getPose(cMo);
131 tracker->setPose(I, cMo);
143 vpImage<unsigned char>& I,
144 vpKltOpencv& kltTracker,
145 boost::recursive_mutex& mutex,
146 visp_tracker::ModelBasedSettingsKltConfig& config,
152 ROS_INFO(
"Reconfigure Model Based KLT Tracker request received.");
154 convertModelBasedSettingsConfigToVpMbTracker<visp_tracker::ModelBasedSettingsKltConfig>(config, tracker);
155 convertModelBasedSettingsConfigToVpKltOpencv<visp_tracker::ModelBasedSettingsKltConfig>(config, kltTracker, tracker);
158 if (I.getHeight() != 0 && I.getWidth() != 0) {
159 vpHomogeneousMatrix cMo;
160 tracker->getPose(cMo);
161 tracker->initFromPose(I, cMo);
173 vpMbTracker* tracker)
177 visp_tracker::Init srv;
179 if (clientViewer.
call(srv))
181 if (srv.response.initialization_succeed)
182 ROS_INFO(
"Tracker Viewer initialized with success.");
184 throw std::runtime_error(
"failed to initialize tracker viewer.");
189 vpMbTracker* tracker,
190 vpImage<unsigned char>& I,
192 vpKltOpencv& kltTracker,
193 boost::recursive_mutex& mutex,
194 visp_tracker::ModelBasedSettingsConfig& config,
202 vpMbTracker* tracker,
203 vpImage<unsigned char>& I,
205 boost::recursive_mutex& mutex,
206 visp_tracker::ModelBasedSettingsEdgeConfig& config,
214 vpMbTracker* tracker,
215 vpImage<unsigned char>& I,
216 vpKltOpencv& kltTracker,
217 boost::recursive_mutex& mutex,
218 visp_tracker::ModelBasedSettingsKltConfig& config,
void reconfigureKltCallbackAndInitViewer(ros::NodeHandle &nh, vpMbTracker *tracker, vpImage< unsigned char > &I, vpKltOpencv &kltTracker, boost::recursive_mutex &mutex, visp_tracker::ModelBasedSettingsKltConfig &config, uint32_t level)
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void reconfigureCallback(vpMbTracker *tracker, vpImage< unsigned char > &I, vpMe &moving_edge, vpKltOpencv &kltTracker, boost::recursive_mutex &mutex, visp_tracker::ModelBasedSettingsConfig &config, uint32_t level)
image_transport::CameraSubscriber::Callback bindImageCallback(vpImage< unsigned char > &image)
bool call(MReq &req, MRes &res)
void convertVpMbTrackerToInitRequest(const vpMbTracker *tracker, visp_tracker::Init &srv)
void reInitViewerCommonParameters(ros::NodeHandle &nh, vpMbTracker *tracker)
void reconfigureEdgeCallbackAndInitViewer(ros::NodeHandle &nh, vpMbTracker *tracker, vpImage< unsigned char > &I, vpMe &moving_edge, boost::recursive_mutex &mutex, visp_tracker::ModelBasedSettingsEdgeConfig &config, uint32_t level)
void reconfigureCallbackAndInitViewer(ros::NodeHandle &nh, vpMbTracker *tracker, vpImage< unsigned char > &I, vpMe &moving_edge, vpKltOpencv &kltTracker, boost::recursive_mutex &mutex, visp_tracker::ModelBasedSettingsConfig &config, uint32_t level)
void imageCallback(vpImage< unsigned char > &image, const sensor_msgs::Image::ConstPtr &msg, const sensor_msgs::CameraInfoConstPtr &info)
void reconfigureEdgeCallback(vpMbTracker *tracker, vpImage< unsigned char > &I, vpMe &moving_edge, boost::recursive_mutex &mutex, visp_tracker::ModelBasedSettingsEdgeConfig &config, uint32_t level)
std::string reconfigure_service_viewer
void reconfigureKltCallback(vpMbTracker *tracker, vpImage< unsigned char > &I, vpKltOpencv &kltTracker, boost::recursive_mutex &mutex, visp_tracker::ModelBasedSettingsKltConfig &config, uint32_t level)
boost::function< void(const sensor_msgs::ImageConstPtr &, const sensor_msgs::CameraInfoConstPtr &)> Callback
#define ROS_ERROR_STREAM(args)
void rosImageToVisp(vpImage< unsigned char > &dst, const sensor_msgs::Image::ConstPtr &src)
Convert a ROS image into a ViSP one.