00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef PCL_COMMON_H_
00039 #define PCL_COMMON_H_
00040
00041 #include <pcl/pcl_base.h>
00042 #include <pcl/io/io.h>
00043 #include <cfloat>
00044
00045
00046
00047
00048
00049 namespace pcl
00050 {
00056 inline double getAngle3D (const Eigen::Vector4f &v1, const Eigen::Vector4f &v2);
00057
00063 inline void getMeanStd (const std::vector<float> &values, double &mean, double &stddev);
00064
00071 template <typename PointT>
00072 inline void getPointsInBox (const pcl::PointCloud<PointT> &cloud, Eigen::Vector4f &min_pt,
00073 Eigen::Vector4f &max_pt, std::vector<int> &indices);
00074
00080 template<typename PointT>
00081 inline void
00082 getMaxDistance (const pcl::PointCloud<PointT> &cloud, const Eigen::Vector4f &pivot_pt, Eigen::Vector4f &max_pt);
00083
00090 template<typename PointT>
00091 inline void
00092 getMaxDistance (const pcl::PointCloud<PointT> &cloud, const std::vector<int> &indices, const Eigen::Vector4f &pivot_pt,
00093 Eigen::Vector4f &max_pt);
00094
00100 template <typename PointT>
00101 inline void getMinMax3D (const pcl::PointCloud<PointT> &cloud, PointT &min_pt, PointT &max_pt);
00102
00108 template <typename PointT>
00109 inline void getMinMax3D (const pcl::PointCloud<PointT> &cloud, Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt);
00110
00117 template <typename PointT>
00118 inline void getMinMax3D (const pcl::PointCloud<PointT> &cloud, const std::vector<int> &indices,
00119 Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt);
00120
00127 template <typename PointT>
00128 inline void getMinMax3D (const pcl::PointCloud<PointT> &cloud, const pcl::PointIndices &indices,
00129 Eigen::Vector4f &min_pt, Eigen::Vector4f &max_pt);
00130
00137 template <typename PointT>
00138 inline double getCircumcircleRadius (const PointT &pa, const PointT &pb, const PointT &pc);
00139
00146 template <typename PointT>
00147 inline void getMinMax (const PointT &histogram, int len, float &min_p, float &max_p);
00148
00156 inline void
00157 getMinMax (const sensor_msgs::PointCloud2 &cloud, int idx, const std::string &field_name,
00158 float &min_p, float &max_p)
00159 {
00160 min_p = FLT_MAX;
00161 max_p = -FLT_MAX;
00162
00163 int field_idx = pcl::getFieldIndex (cloud, field_name);
00164 if (field_idx == -1)
00165 {
00166 ROS_ERROR ("[getMinMax] Invalid field (%s) given!", field_name.c_str ());
00167 return;
00168 }
00169
00170 for (unsigned int i = 0; i < cloud.fields[field_idx].count; ++i)
00171 {
00172 float data;
00173
00174 memcpy (&data, &cloud.data[cloud.fields[field_idx].offset + i * sizeof (float)], sizeof (float));
00175 min_p = (data > min_p) ? min_p : data;
00176 max_p = (data < max_p) ? max_p : data;
00177 }
00178 }
00179
00185 inline void
00186 getMeanStdDev (const std::vector<float> &values, double &mean, double &stddev)
00187 {
00188 double sum = 0, sq_sum = 0;
00189
00190 for (size_t i = 0; i < values.size (); ++i)
00191 {
00192 sum += values[i];
00193 sq_sum += values[i] * values[i];
00194 }
00195 mean = sum / values.size ();
00196 double variance = (double)(sq_sum - sum * sum / values.size ()) / (values.size () - 1);
00197 stddev = sqrt (variance);
00198 }
00199
00200 }
00201
00202 #include "pcl/common/common.hpp"
00203
00204 #endif //#ifndef PCL_COMMON_H_