21 #include <boost/algorithm/string.hpp> 23 #include <boost/lexical_cast.hpp> 24 #include <boost/accumulators/accumulators.hpp> 25 #include <boost/accumulators/statistics/stats.hpp> 26 #include <boost/accumulators/statistics/median.hpp> 27 #include <boost/accumulators/statistics/weighted_median.hpp> 39 std::vector<std::string> strvec;
41 boost::algorithm::trim_if(input_string, boost::algorithm::is_any_of(delim));
42 boost::algorithm::split(strvec, input_string, boost::algorithm::is_any_of(delim), boost::algorithm::token_compress_on);
44 Eigen::Vector3d vector;
45 for(
unsigned int i=0; i < strvec.size(); i++) {
46 vector[i] = boost::lexical_cast<
double>(strvec[i]);
54 std::vector<std::string> strvec;
56 boost::algorithm::trim_if(input_string, boost::algorithm::is_any_of(delim));
57 boost::algorithm::split(strvec, input_string, boost::algorithm::is_any_of(delim), boost::algorithm::token_compress_on);
59 Eigen::Vector2i vector;
60 for(
unsigned int i=0; i < strvec.size(); i++) {
61 vector[i] = boost::lexical_cast<
int>(strvec[i]);
69 if (points.size() > 0) {
70 Eigen::Vector3d median_point = points.at(0);
72 for (
unsigned int i = 0; i < 3; i++) {
73 std::vector<double> nums;
74 for (
unsigned int j = 0; j < points.size(); j++) {
75 nums.push_back(points.at(j)[i]);
77 std::sort(nums.begin(), nums.end());
78 if (nums.size() % 2 == 0) {
79 median_point(i) = (nums[nums.size() / 2 - 1] + nums[nums.size() / 2]) / 2;
81 median_point(i) = nums[nums.size() / 2];
86 return Eigen::Vector3d(0, 0, 0);
91 if (points.size() > 0) {
92 std::vector<Eigen::Vector3d> points_eigen;
93 for (
unsigned i = 0; i < points.size(); i++) {
94 if (pcl::isFinite(points.at(i))) {
95 points_eigen.push_back(Eigen::Vector3d(points.at(i).x, points.at(i).y, points.at(i).z));
99 return pcl::PointXYZ(median_point[0], median_point[1], median_point[2]);
101 return pcl::PointXYZ();
104 pcl::PointXYZ
findPoint3D(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, pcl::PointXYZ current_point,
int row,
int column,
int image_height,
int image_width) {
105 int step_counter = 1;
106 bool finite_found =
false;
107 while ((!pcl::isFinite(current_point)) && (row > 1) && (column > 1) && (row < image_height - 1 - step_counter) && (column < image_width - 1 - step_counter)) {
108 for (
int i = 1; i <= step_counter; i++) {
110 current_point = (*cloud)(column, row);
111 if (pcl::isFinite(current_point)) {
116 if (finite_found)
break;
117 for (
int i = 1; i <= step_counter; i++) {
119 current_point = (*cloud)(column, row);
120 if (pcl::isFinite(current_point)) {
125 if (finite_found)
break;
127 for (
int i = 1; i <= step_counter; i++) {
129 current_point = (*cloud)(column, row);
130 if (pcl::isFinite(current_point)) {
135 if (finite_found)
break;
136 for (
int i = 1; i <= step_counter; i++) {
138 current_point = (*cloud)(column, row);
139 if (pcl::isFinite(current_point)) {
144 if (finite_found)
break;
147 return current_point;
153 double hh, p, q, t, ff;
164 if(hh >= 360.0) hh = 0.0;
168 p = in.
v * (1.0 - in.
s);
169 q = in.
v * (1.0 - (in.
s * ff));
170 t = in.
v * (1.0 - (in.
s * (1.0 - ff)));
pcl::PointXYZ findPoint3D(pcl::PointCloud< pcl::PointXYZ >::Ptr cloud, pcl::PointXYZ current_point, int row, int column, int image_height, int image_width)
Finds the corresponding 3D point to the given 2D point.
Eigen::Vector3d parseStringVector(std::string input_string, std::string delim)
Parses the given string and returns the 3D-double-vector described by it.
Eigen::Vector3d computeMedian(std::vector< Eigen::Vector3d > points)
Computes the median of the given points.
rgb hsv2rgb(hsv in)
Converts the given hsv-color to rgb.
Eigen::Vector2i parseStringVector2i(std::string input_string, std::string delim)
Parses the given string and returns the 2D-int-vector described by it.