Changing Tracking Color with Messages
From wikidb
Instance variables: add color parameters.
class Demo { protected: ... int min_hue_; int max_hue_; int min_saturation_;
Constructor: Add a subscriber for /hue_set messages.
Constructor: Init the color parameters.
public: Demo (ros::NodeHandle & nh):nh_ (nh), it_ (nh_) { ... hue_set_sub_ = nh_.subscribe("/hue_set", 1000, &Demo::hueSetCallback, this); min_hue_ = 6; max_hue_ = 26; min_saturation_ = 96; }
Callback function: Set new color parameters.
void hueSetCallback (const geometry_msgs::Point::ConstPtr & hue_set_msg) { ROS_INFO("*** In hueSetCallback: x: %d y: %d z: %d", (int)(hue_set_msg->x), (int)(hue_set_msg->y), (int)(hue_set_msg->z)); min_hue_ = (int)(hue_set_msg->x); max_hue_ = (int)(hue_set_msg->y); min_saturation_ = (int)(hue_set_msg->z); }
rostopic pub -1 /hue_set geometry_msgs/Point 95 105 100