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/point_types.h> 57 #include <pcl/point_cloud.h> 58 #include <pcl/PointIndices.h> 59 #include <pcl/filters/extract_indices.h> 60 #include <pcl/ModelCoefficients.h> 61 #include <pcl/filters/project_inliers.h> 62 #include <pcl/surface/concave_hull.h> 63 #include <visualization_msgs/Marker.h> 68 #include <jsk_recognition_msgs/PolygonArray.h> 83 const Eigen::Vector3f& v) {
84 ROS_INFO(
"%s: [%f, %f, %f]", prefix.c_str(), v[0], v[1], v[2]);
93 Eigen::Quaternionf
rotFrom3Axis(
const Eigen::Vector3f& ex,
94 const Eigen::Vector3f& ey,
95 const Eigen::Vector3f& ez);
100 template<
class Po
intT>
103 typename pcl::PointCloud<PointT>::Ptr cloud (
new pcl::PointCloud<PointT>);
104 for (
size_t i = 0; i < v.size(); i++) {
112 cloud->points.push_back(p);
121 template<
class Po
intT>
125 for (
size_t i = 0; i < cloud.points.size(); i++) {
126 Eigen::Vector3f
p(cloud.points[i].getVector3fMap());
135 std::vector<pcl::ModelCoefficients::Ptr>);
137 template <
class Po
intT>
140 Eigen::Vector4f minpt, maxpt;
141 pcl::getMinMax3D<PointT>(cloud, minpt, maxpt);
142 jsk_recognition_msgs::BoundingBox bbox;
143 bbox.dimensions.x = std::abs(minpt[0] - maxpt[0]);
144 bbox.dimensions.y = std::abs(minpt[1] - maxpt[1]);
145 bbox.dimensions.z = std::abs(minpt[2] - maxpt[2]);
146 bbox.pose.position.x = (minpt[0] + maxpt[0]) / 2.0;
147 bbox.pose.position.y = (minpt[1] + maxpt[1]) / 2.0;
148 bbox.pose.position.z = (minpt[2] + maxpt[2]) / 2.0;
149 bbox.pose.orientation.w = 1.0;
std::vector< Plane::Ptr > convertToPlanes(std::vector< pcl::ModelCoefficients::Ptr >)
void ROS_INFO_EIGEN_VECTOR3(const std::string &prefix, const Eigen::Vector3f &v)
pcl::PointCloud< PointT >::Ptr verticesToPointCloud(const Vertices &v)
Compute PointCloud from Vertices.
Eigen::Quaternionf rotFrom3Axis(const Eigen::Vector3f &ex, const Eigen::Vector3f &ey, const Eigen::Vector3f &ez)
std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > Vertices
Vertices pointCloudToVertices(const pcl::PointCloud< PointT > &cloud)
Compute Vertices from PointCloud.
jsk_recognition_msgs::BoundingBox boundingBoxFromPointCloud(const pcl::PointCloud< PointT > &cloud)