continuous_detector.cpp
Go to the documentation of this file.
1 
33 
35 
37 
38 namespace apriltag_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  // AprilTag 2 on the iamge
73  try
74  {
75  cv_image_ = cv_bridge::toCvCopy(image_rect, image_rect->encoding);
76  }
77  catch (cv_bridge::Exception& e)
78  {
79  ROS_ERROR("cv_bridge exception: %s", e.what());
80  return;
81  }
82 
83  // Publish detected tags in the image by AprilTag 2
85  tag_detector_->detectTags(cv_image_,camera_info));
86 
87  // Publish the camera image overlaid by outlines of the detected tags and
88  // their payload values
90  {
91  tag_detector_->drawDetections(cv_image_);
93  }
94 }
95 
96 } // namespace apriltag_ros
void publish(const boost::shared_ptr< M > &message) const
image_transport::CameraSubscriber camera_image_subscriber_
ros::NodeHandle & getPrivateNodeHandle() const
std::shared_ptr< TagDetector > tag_detector_
void publish(const sensor_msgs::Image &message) const
image_transport::Publisher tag_detections_image_publisher_
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
void imageCallback(const sensor_msgs::ImageConstPtr &image_rect, const sensor_msgs::CameraInfoConstPtr &camera_info)
#define ROS_ERROR(...)
PLUGINLIB_EXPORT_CLASS(apriltag_ros::ContinuousDetector, nodelet::Nodelet)


apriltag_ros
Author(s): Danylo Malyuta
autogenerated on Thu Jul 16 2020 03:53:54