36 #ifndef JSK_RECOGNITION_UTILS_GEO_UTIL_H_
37 #define JSK_RECOGNITION_UTILS_GEO_UTIL_H_
41 #include <Eigen/Geometry>
42 #include <Eigen/StdVector>
46 #include <boost/shared_ptr.hpp>
47 #include <boost/thread.hpp>
48 #include <geometry_msgs/Polygon.h>
49 #include <jsk_recognition_msgs/BoundingBox.h>
50 #include <jsk_recognition_msgs/SimpleOccupancyGrid.h>
51 #include <boost/tuple/tuple.hpp>
56 #include <pcl/common/common.h>
57 #include <pcl/point_types.h>
58 #include <pcl/point_cloud.h>
59 #include <pcl/PointIndices.h>
60 #include <pcl/filters/extract_indices.h>
61 #include <pcl/ModelCoefficients.h>
62 #include <pcl/filters/project_inliers.h>
63 #include <pcl/surface/concave_hull.h>
64 #include <visualization_msgs/Marker.h>
69 #include <jsk_recognition_msgs/PolygonArray.h>
84 const Eigen::Vector3f& v) {
94 Eigen::Quaternionf
rotFrom3Axis(
const Eigen::Vector3f& ex,
95 const Eigen::Vector3f& ey,
96 const Eigen::Vector3f& ez);
101 template<
class Po
intT>
104 typename pcl::PointCloud<PointT>::Ptr cloud (
new pcl::PointCloud<PointT>);
105 for (
size_t i = 0;
i < v.size();
i++) {
113 cloud->points.push_back(
p);
122 template<
class Po
intT>
126 for (
size_t i = 0;
i < cloud.points.size();
i++) {
127 Eigen::Vector3f
p(cloud.points[
i].getVector3fMap());
136 std::vector<pcl::ModelCoefficients::Ptr>);
138 template <
class Po
intT>
141 Eigen::Vector4f minpt, maxpt;
142 pcl::getMinMax3D<PointT>(cloud, minpt, maxpt);
143 jsk_recognition_msgs::BoundingBox bbox;
144 bbox.dimensions.x = std::abs(minpt[0] - maxpt[0]);
145 bbox.dimensions.y = std::abs(minpt[1] - maxpt[1]);
146 bbox.dimensions.z = std::abs(minpt[2] - maxpt[2]);
147 bbox.pose.position.x = (minpt[0] + maxpt[0]) / 2.0;
148 bbox.pose.position.y = (minpt[1] + maxpt[1]) / 2.0;
149 bbox.pose.position.z = (minpt[2] + maxpt[2]) / 2.0;
150 bbox.pose.orientation.w = 1.0;