38 #include <jsk_recognition_msgs/ParallelEdgeArray.h>
44 ConnectionBasedNodelet::onInit();
49 pub_ = advertise<jsk_recognition_msgs::ParallelEdgeArray>(*pnh_,
"output_edges_groups", 1);
50 pub_clusters_ = advertise<jsk_recognition_msgs::ClusterPointIndices>(*pnh_,
"output_clusters", 1);
55 srv_ = boost::make_shared <dynamic_reconfigure::Server<Config> > (*pnh_);
56 dynamic_reconfigure::Server<Config>::CallbackType
f =
58 srv_->setCallback (
f);
80 sync_ = boost::make_shared<message_filters::Synchronizer<SyncPolicy> >(100);
93 Config &config, uint32_t level)
100 const jsk_recognition_msgs::ClusterPointIndices::ConstPtr& input_indices,
101 const jsk_recognition_msgs::ModelCoefficientsArray::ConstPtr& input_coefficients)
107 std::vector<jsk_recognition_utils::Line::Ptr>
lines;
108 if (input_coefficients->coefficients.size() == 0) {
111 for (
size_t i = 0;
i < input_coefficients->coefficients.size();
i++) {
112 std::vector<float> the_coefficients
113 = input_coefficients->coefficients[
i].values;
117 std::map<int, std::vector<int> > parallel_map;
118 for (
size_t i = 0;
i <
lines.size() - 1;
i++) {
119 parallel_map[
i] = std::vector<int>();
121 for (
size_t j =
i + 1; j <
lines.size(); j++) {
124 parallel_map[
i].push_back(j);
131 std::vector<std::set<int> > parallel_groups_list;
135 std::set<int> listed_indices;
137 for (
size_t i = 0;
i <
lines.size() - 1;
i++) {
138 std::vector<int> parallel_indices = parallel_map[
i];
139 if (listed_indices.find(
i) == listed_indices.end()) {
140 if (parallel_indices.size() == 0) {
144 std::set<int> new_parallel_set;
149 parallel_groups_list.push_back(new_parallel_set);
155 publishResult(parallel_groups_list, input_indices, input_coefficients);
161 const std::vector<std::set<int> >& parallel_groups_list,
162 const jsk_recognition_msgs::ClusterPointIndices::ConstPtr& input_indices,
163 const jsk_recognition_msgs::ModelCoefficientsArray::ConstPtr& input_coefficients)
165 jsk_recognition_msgs::ParallelEdgeArray ros_output_msg;
166 ros_output_msg.header = input_indices->header;
167 for (
size_t i = 0;
i < parallel_groups_list.size();
i++) {
168 std::set<int> parallel_groups = parallel_groups_list[
i];
169 jsk_recognition_msgs::ParallelEdge edge_group;
170 edge_group.header = input_indices->header;
171 for (std::set<int>::iterator it = parallel_groups.begin();
172 it != parallel_groups.end();
175 std::vector<int> indices
176 = input_indices->cluster_indices[the_index].indices;
178 = input_coefficients->coefficients[the_index].values;
180 indices_msg.header = input_indices->header;
181 indices_msg.indices = indices;
183 coefficients_msg.header = input_coefficients->header;
185 edge_group.cluster_indices.push_back(indices_msg);
186 edge_group.coefficients.push_back(coefficients_msg);
188 ros_output_msg.edge_groups.push_back(edge_group);
194 const std::vector<std::set<int> >& parallel_groups_list,
195 const jsk_recognition_msgs::ClusterPointIndices::ConstPtr& input_indices,
196 const jsk_recognition_msgs::ModelCoefficientsArray::ConstPtr& input_coefficients)
198 jsk_recognition_msgs::ClusterPointIndices ros_output_msg;
199 ros_output_msg.header = input_indices->header;
201 for (
size_t i = 0;
i < parallel_groups_list.size();
i++) {
202 std::set<int> parallel_groups = parallel_groups_list[
i];
204 indices_msg.header = input_indices->header;
205 for (std::set<int>::iterator it = parallel_groups.begin();
206 it != parallel_groups.end();
210 input_indices->cluster_indices[*it].indices);
212 ros_output_msg.cluster_indices.push_back(indices_msg);