continuous_detector.cpp
Go to the documentation of this file.
1 
33 
35 
37 
38 namespace apriltags2_ros
39 {
40 
42 {
43 }
44 
46 {
49 
50  tag_detector_ = std::shared_ptr<TagDetector>(new TagDetector(pnh));
51  draw_tag_detections_image_ = getAprilTagOption<bool>(pnh,
52  "publish_tag_detections_image", false);
53  it_ = std::shared_ptr<image_transport::ImageTransport>(
55 
57  it_->subscribeCamera("image_rect", 1,
60  nh.advertise<AprilTagDetectionArray>("tag_detections", 1);
61  if (draw_tag_detections_image_)
62  {
63  tag_detections_image_publisher_ = it_->advertise("tag_detections_image", 1);
64  }
65 }
66 
68  const sensor_msgs::ImageConstPtr& image_rect,
69  const sensor_msgs::CameraInfoConstPtr& camera_info)
70 {
71  // Convert ROS's sensor_msgs::Image to cv_bridge::CvImagePtr in order to run
72  // AprilTags 2 on the iamge
73  try
74  {
75  cv_image_ = cv_bridge::toCvCopy(image_rect,
77  }
78  catch (cv_bridge::Exception& e)
79  {
80  ROS_ERROR("cv_bridge exception: %s", e.what());
81  return;
82  }
83 
84  // Publish detected tags in the image by AprilTags 2
86  tag_detector_->detectTags(cv_image_,camera_info));
87 
88  // Publish the camera image overlaid by outlines of the detected tags and
89  // their payload values
91  {
92  tag_detector_->drawDetections(cv_image_);
94  }
95 }
96 
97 } // namespace apriltags2_ros
PLUGINLIB_EXPORT_CLASS(apriltags2_ros::ContinuousDetector, nodelet::Nodelet)
void publish(const boost::shared_ptr< M > &message) const
void imageCallback(const sensor_msgs::ImageConstPtr &image_rect, const sensor_msgs::CameraInfoConstPtr &camera_info)
image_transport::Publisher tag_detections_image_publisher_
ros::NodeHandle & getPrivateNodeHandle() const
void publish(const sensor_msgs::Image &message) const
CvImagePtr toCvCopy(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
std::shared_ptr< image_transport::ImageTransport > it_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::NodeHandle & getNodeHandle() const
image_transport::CameraSubscriber camera_image_subscriber_
std::shared_ptr< TagDetector > tag_detector_
#define ROS_ERROR(...)


apriltags2_ros
Author(s): Danylo Malyuta
autogenerated on Fri Oct 19 2018 04:02:45