linemod.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 
37 #ifndef JSK_PCL_ROS_LINEMOD_H_
38 #define JSK_PCL_ROS_LINEMOD_H_
39 
42 #include <jsk_topic_tools/diagnostic_nodelet.h>
43 #include <pcl/recognition/linemod/line_rgbd.h>
44 #include <pcl/recognition/color_gradient_modality.h>
45 #include <pcl/recognition/surface_normal_modality.h>
46 
47 #include <jsk_pcl_ros/LINEMODDetectorConfig.h>
48 #include <sensor_msgs/PointCloud2.h>
49 #include <sensor_msgs/CameraInfo.h>
50 #include <dynamic_reconfigure/server.h>
51 
52 #include <std_srvs/Empty.h>
56 #include <pcl/recognition/linemod.h>
57 #include <pcl/recognition/color_gradient_modality.h>
58 #include <pcl/recognition/surface_normal_modality.h>
59 #include <jsk_recognition_msgs/BoundingBox.h>
60 #include <jsk_recognition_msgs/BoundingBoxArray.h>
61 #include <pcl_ros/pcl_nodelet.h>
62 #include <yaml-cpp/yaml.h>
63 
64 namespace jsk_pcl_ros
65 {
66  class LINEMODDetector: public jsk_topic_tools::DiagnosticNodelet
67  {
68  public:
69  typedef LINEMODDetectorConfig Config;
70  LINEMODDetector(): DiagnosticNodelet("LINEMODDetector") {}
71  protected:
73  // methods
75  virtual void onInit();
76  virtual void subscribe();
77  virtual void unsubscribe();
78  virtual void setTemplate(YAML::Node doc);
79  virtual void detect(
80  const sensor_msgs::PointCloud2::ConstPtr& cloud_msg);
81  virtual void configCallback(
82  Config& config, uint32_t level);
83  virtual void computeCenterOfTemplate(
84  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud,
85  const pcl::SparseQuantizedMultiModTemplate& linemod_template,
86  const pcl::LINEMODDetection& linemod_detection,
87  Eigen::Vector3f& center);
89  // ROS variables
98 
100  // Parameters
102  std::string template_file_;
104  double detection_threshold_;
105  //pcl::LineRGBD<pcl::PointXYZRGBA> line_rgbd_;
106  pcl::LINEMOD linemod_;
107  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr template_cloud_;
108  std::vector<Eigen::Affine3f> template_poses_;
109  std::vector<jsk_recognition_msgs::BoundingBox> template_bboxes_;
110  pcl::ColorGradientModality<pcl::PointXYZRGBA> color_gradient_mod_;
111  pcl::SurfaceNormalModality<pcl::PointXYZRGBA> surface_normal_mod_;
112  private:
113 
114  };
115 
116  class LINEMODTrainer: public pcl_ros::PCLNodelet
117  {
118  public:
121  sensor_msgs::PointCloud2,
123  virtual ~LINEMODTrainer();
124  protected:
126  // methods
128  virtual void onInit();
129  virtual void store(
130  const sensor_msgs::PointCloud2::ConstPtr& cloud_msg,
131  const PCLIndicesMsg::ConstPtr& indices_msg);
132  virtual void subscribeCloud(
133  const sensor_msgs::PointCloud2::ConstPtr& cloud_msg);
134  virtual void subscribeCameraInfo(
135  const sensor_msgs::CameraInfo::ConstPtr& info_msg);
136  virtual bool startTraining(std_srvs::Empty::Request& req,
137  std_srvs::Empty::Response& res);
138  virtual std::vector<std::string> trainOneData(
139  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud,
140  pcl::PointIndices::Ptr mask,
141  std::string& tempstr,
142  int i);
143  virtual void tar(const std::string& directory, const std::string& output);
144  virtual bool clearData(std_srvs::Empty::Request& req,
145  std_srvs::Empty::Response& res);
146  virtual void trainWithoutViewpointSampling();
147  virtual void trainWithViewpointSampling();
149  const Eigen::Affine3f& transform,
150  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr raw_cloud,
152  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr output,
153  pcl::PointIndices& mask);
155  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud,
156  pcl::PointIndices::Ptr mask,
157  pcl::ColorGradientModality<pcl::PointXYZRGBA>& color_grad_mod,
158  pcl::SurfaceNormalModality<pcl::PointXYZRGBA>& surface_norm_mod,
159  pcl::MaskMap& mask_map,
160  pcl::RegionXY& region);
162  // variables
174  sensor_msgs::CameraInfo::ConstPtr camera_info_;
175  std::vector<pcl::PointCloud<pcl::PointXYZRGBA>::Ptr> samples_before_sampling_;
176  std::vector<pcl::PointCloud<pcl::PointXYZRGBA>::Ptr> samples_;
177  std::vector<pcl::PointIndices::Ptr> sample_indices_;
179  std::string output_file_;
180  bool sample_viewpoint_;
187  int n_points_;
188  private:
189 
190  };
191 }
192 
193 
194 #endif
jsk_pcl_ros::LINEMODDetector::onInit
virtual void onInit()
Definition: linemod_nodelet.cpp:564
jsk_pcl_ros::LINEMODTrainer::sample_viewpoint_angle_min_
double sample_viewpoint_angle_min_
Definition: linemod.h:215
jsk_pcl_ros::LINEMODTrainer::sample_indices_
std::vector< pcl::PointIndices::Ptr > sample_indices_
Definition: linemod.h:209
ros::Publisher
pcl_ros::PCLNodelet
jsk_pcl_ros::LINEMODTrainer::pub_colored_range_image_
ros::Publisher pub_colored_range_image_
Definition: linemod.h:202
jsk_pcl_ros::LINEMODTrainer::camera_info_
sensor_msgs::CameraInfo::ConstPtr camera_info_
Definition: linemod.h:206
jsk_pcl_ros::LINEMODDetector::pub_detect_mask_
ros::Publisher pub_detect_mask_
Definition: linemod.h:157
boost::shared_ptr
jsk_pcl_ros::LINEMODTrainer::subscribeCloud
virtual void subscribeCloud(const sensor_msgs::PointCloud2::ConstPtr &cloud_msg)
Definition: linemod_nodelet.cpp:143
jsk_pcl_ros::LINEMODDetector::color_gradient_mod_
pcl::ColorGradientModality< pcl::PointXYZRGBA > color_gradient_mod_
Definition: linemod.h:174
pinhole_camera_model.h
jsk_pcl_ros::LINEMODTrainer::start_training_srv_
ros::ServiceServer start_training_srv_
Definition: linemod.h:199
jsk_pcl_ros::LINEMODTrainer::pub_range_image_
ros::Publisher pub_range_image_
Definition: linemod.h:201
jsk_pcl_ros::LINEMODTrainer::generateLINEMODTrainingData
virtual void generateLINEMODTrainingData(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr cloud, pcl::PointIndices::Ptr mask, pcl::ColorGradientModality< pcl::PointXYZRGBA > &color_grad_mod, pcl::SurfaceNormalModality< pcl::PointXYZRGBA > &surface_norm_mod, pcl::MaskMap &mask_map, pcl::RegionXY &region)
Definition: linemod_nodelet.cpp:400
jsk_pcl_ros::LINEMODDetector::linemod_
pcl::LINEMOD linemod_
Definition: linemod.h:170
jsk_pcl_ros::LINEMODTrainer::sync_
boost::shared_ptr< message_filters::Synchronizer< SyncPolicy > > sync_
Definition: linemod.h:196
jsk_pcl_ros::LINEMODDetector::subscribe
virtual void subscribe()
Definition: linemod_nodelet.cpp:604
PCLIndicesMsg
pcl::PointIndices PCLIndicesMsg
jsk_pcl_ros::LINEMODTrainer::clearData
virtual bool clearData(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Definition: linemod_nodelet.cpp:161
jsk_pcl_ros::LINEMODTrainer::sample_viewpoint_angle_max_
double sample_viewpoint_angle_max_
Definition: linemod.h:217
jsk_pcl_ros::LINEMODDetector::detect
virtual void detect(const sensor_msgs::PointCloud2::ConstPtr &cloud_msg)
Definition: linemod_nodelet.cpp:683
jsk_pcl_ros::LINEMODDetector::template_cloud_
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr template_cloud_
Definition: linemod.h:171
jsk_pcl_ros::LINEMODTrainer::sample_viewpoint_angle_step_
double sample_viewpoint_angle_step_
Definition: linemod.h:213
jsk_pcl_ros::LINEMODTrainer::n_points_
int n_points_
Definition: linemod.h:219
time_synchronizer.h
jsk_pcl_ros::LINEMODTrainer::Ptr
boost::shared_ptr< LINEMODTrainer > Ptr
Definition: linemod.h:151
jsk_pcl_ros::LINEMODTrainer::pub_sample_cloud_
ros::Publisher pub_sample_cloud_
Definition: linemod.h:203
jsk_pcl_ros::LINEMODTrainer::sub_camera_info_nonsync_
ros::Subscriber sub_camera_info_nonsync_
Definition: linemod.h:205
jsk_pcl_ros::LINEMODDetector::unsubscribe
virtual void unsubscribe()
Definition: linemod_nodelet.cpp:609
jsk_pcl_ros::LINEMODTrainer::trainWithoutViewpointSampling
virtual void trainWithoutViewpointSampling()
Definition: linemod_nodelet.cpp:521
jsk_pcl_ros::LINEMODTrainer::samples_
std::vector< pcl::PointCloud< pcl::PointXYZRGBA >::Ptr > samples_
Definition: linemod.h:208
message_filters::Subscriber< sensor_msgs::PointCloud2 >
ros::ServiceServer
jsk_pcl_ros::LINEMODTrainer::sub_input_nonsync_
ros::Subscriber sub_input_nonsync_
Definition: linemod.h:204
pcl_nodelet.h
jsk_pcl_ros::LINEMODTrainer::trainOneData
virtual std::vector< std::string > trainOneData(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr cloud, pcl::PointIndices::Ptr mask, std::string &tempstr, int i)
Definition: linemod_nodelet.cpp:443
jsk_pcl_ros::LINEMODDetector::LINEMODDetector
LINEMODDetector()
Definition: linemod.h:134
jsk_pcl_ros
Definition: add_color_from_image.h:51
jsk_pcl_ros::LINEMODTrainer::sample_viewpoint_radius_max_
double sample_viewpoint_radius_max_
Definition: linemod.h:218
jsk_pcl_ros::LINEMODDetector::configCallback
virtual void configCallback(Config &config, uint32_t level)
Definition: linemod_nodelet.cpp:633
jsk_pcl_ros::LINEMODDetector::template_poses_
std::vector< Eigen::Affine3f > template_poses_
Definition: linemod.h:172
subscriber.h
jsk_pcl_ros::LINEMODTrainer::samples_before_sampling_
std::vector< pcl::PointCloud< pcl::PointXYZRGBA >::Ptr > samples_before_sampling_
Definition: linemod.h:207
jsk_pcl_ros::LINEMODTrainer::startTraining
virtual bool startTraining(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Definition: linemod_nodelet.cpp:550
jsk_pcl_ros::LINEMODDetector::Config
LINEMODDetectorConfig Config
Definition: linemod.h:133
jsk_pcl_ros::LINEMODDetector::template_bboxes_
std::vector< jsk_recognition_msgs::BoundingBox > template_bboxes_
Definition: linemod.h:173
jsk_pcl_ros::LINEMODDetector::pub_pose_
ros::Publisher pub_pose_
Definition: linemod.h:158
jsk_pcl_ros::LINEMODTrainer
Definition: linemod.h:148
pcl_conversion_util.h
jsk_pcl_ros::LINEMODTrainer::store
virtual void store(const sensor_msgs::PointCloud2::ConstPtr &cloud_msg, const PCLIndicesMsg::ConstPtr &indices_msg)
Definition: linemod_nodelet.cpp:128
jsk_pcl_ros::LINEMODTrainer::sample_viewpoint_radius_step_
double sample_viewpoint_radius_step_
Definition: linemod.h:214
jsk_pcl_ros::LINEMODTrainer::tar
virtual void tar(const std::string &directory, const std::string &output)
Definition: linemod_nodelet.cpp:542
jsk_pcl_ros::LINEMODTrainer::organizedPointCloudWithViewPoint
virtual void organizedPointCloudWithViewPoint(const Eigen::Affine3f &transform, pcl::PointCloud< pcl::PointXYZRGBA >::Ptr raw_cloud, const image_geometry::PinholeCameraModel &model, pcl::PointCloud< pcl::PointXYZRGBA >::Ptr output, pcl::PointIndices &mask)
Definition: linemod_nodelet.cpp:172
depth_error_calibration.model
model
Definition: depth_error_calibration.py:37
jsk_pcl_ros::LINEMODTrainer::trainWithViewpointSampling
virtual void trainWithViewpointSampling()
Definition: linemod_nodelet.cpp:272
jsk_pcl_ros::LINEMODDetector::mutex_
boost::mutex mutex_
Definition: linemod.h:160
jsk_pcl_ros::LINEMODTrainer::sample_viewpoint_
bool sample_viewpoint_
Definition: linemod.h:212
jsk_pcl_ros::LINEMODDetector::surface_normal_mod_
pcl::SurfaceNormalModality< pcl::PointXYZRGBA > surface_normal_mod_
Definition: linemod.h:175
jsk_pcl_ros::LINEMODDetector::sub_cloud_
ros::Subscriber sub_cloud_
Definition: linemod.h:155
image_geometry::PinholeCameraModel
jsk_pcl_ros::LINEMODTrainer::sample_viewpoint_radius_min_
double sample_viewpoint_radius_min_
Definition: linemod.h:216
jsk_pcl_ros::LINEMODDetector::detection_threshold_
double detection_threshold_
Definition: linemod.h:168
jsk_pcl_ros::LINEMODDetector::pub_original_template_cloud_
ros::Publisher pub_original_template_cloud_
Definition: linemod.h:159
jsk_pcl_ros::LINEMODTrainer::~LINEMODTrainer
virtual ~LINEMODTrainer()
Definition: linemod_nodelet.cpp:117
jsk_pcl_ros::LINEMODTrainer::sub_indices_
message_filters::Subscriber< PCLIndicesMsg > sub_indices_
Definition: linemod.h:198
synchronizer.h
jsk_pcl_ros::LINEMODTrainer::SyncPolicy
message_filters::sync_policies::ExactTime< sensor_msgs::PointCloud2, PCLIndicesMsg > SyncPolicy
Definition: linemod.h:154
mutex
boost::mutex mutex
global mutex.
Definition: depth_camera_error_visualization.cpp:86
jsk_pcl_ros::LINEMODDetector::pub_cloud_
ros::Publisher pub_cloud_
Definition: linemod.h:156
jsk_pcl_ros::LINEMODTrainer::onInit
virtual void onInit()
Definition: linemod_nodelet.cpp:66
message_filters::sync_policies::ExactTime
jsk_pcl_ros::LINEMODTrainer::output_file_
std::string output_file_
Definition: linemod.h:211
jsk_pcl_ros::LINEMODDetector::computeCenterOfTemplate
virtual void computeCenterOfTemplate(pcl::PointCloud< pcl::PointXYZRGBA >::Ptr cloud, const pcl::SparseQuantizedMultiModTemplate &linemod_template, const pcl::LINEMODDetection &linemod_detection, Eigen::Vector3f &center)
Definition: linemod_nodelet.cpp:654
jsk_pcl_ros::LINEMODTrainer::clear_data_srv_
ros::ServiceServer clear_data_srv_
Definition: linemod.h:200
jsk_pcl_ros::LINEMODTrainer::mutex_
boost::mutex mutex_
Definition: linemod.h:210
jsk_pcl_ros::LINEMODTrainer::sub_input_
message_filters::Subscriber< sensor_msgs::PointCloud2 > sub_input_
Definition: linemod.h:197
jsk_pcl_ros::LINEMODDetector::setTemplate
virtual void setTemplate(YAML::Node doc)
Definition: linemod_nodelet.cpp:614
jsk_pcl_ros::LINEMODDetector::template_file_
std::string template_file_
Definition: linemod.h:166
sample_pointcloud_localization_client.req
req
Definition: sample_pointcloud_localization_client.py:15
jsk_pcl_ros::LINEMODDetector::gradient_magnitude_threshold_
double gradient_magnitude_threshold_
Definition: linemod.h:167
sample_empty_service_caller.res
res
Definition: sample_empty_service_caller.py:14
jsk_pcl_ros::LINEMODDetector::srv_
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
Definition: linemod.h:161
ros::Subscriber
jsk_pcl_ros::LINEMODTrainer::subscribeCameraInfo
virtual void subscribeCameraInfo(const sensor_msgs::CameraInfo::ConstPtr &info_msg)
Definition: linemod_nodelet.cpp:154


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Tue Jan 7 2025 04:05:45