|
@@ -2541,13 +2541,12 @@ void CRootStockGrabPoint::line_filter(
|
|
|
valid_stem_width.push_back(w);
|
|
|
}
|
|
|
}
|
|
|
- float mu = get_hist_mean(valid_stem_width);
|
|
|
- stem_width_mu = mu;
|
|
|
+ float mu = get_hist_mean(valid_stem_width);
|
|
|
float stdv = get_hist_std(valid_stem_width, mu);
|
|
|
|
|
|
//找到茎节
|
|
|
std::vector<int> fork_positions;
|
|
|
- find_fork(in_line_cloud, stem_width_mu, stem_width, fork_positions);
|
|
|
+ find_fork(in_line_cloud, mu, stem_width, fork_positions, stem_width_mu);
|
|
|
for (auto&y : fork_positions) {
|
|
|
fork_ys.push_back(y + ymin);
|
|
|
}
|
|
@@ -2713,12 +2712,14 @@ void CRootStockGrabPoint::line_filter(
|
|
|
pcl::PointCloud<pcl::PointXYZ>::Ptr in_line_cloud,
|
|
|
//float& max_dist,
|
|
|
//int& max_idx,
|
|
|
- float stem_width_mu,
|
|
|
+ float stem_width_ex_mu,//输入, 通过外沿矩形得到的x方向茎粗均值
|
|
|
const std::vector<float>& stem_width_ex,//输入, 通过外沿矩形得到的x方向茎粗
|
|
|
- std::vector<int>&fork_pos //输出, 多个fork位置
|
|
|
+ std::vector<int>&fork_pos, //输出, 多个fork位置
|
|
|
+ float& stem_width_mu //输出, xy投影上x方向的茎粗均值
|
|
|
)
|
|
|
{
|
|
|
fork_pos.clear();
|
|
|
+ stem_width_mu = 0.0;
|
|
|
//1 project to xy plane
|
|
|
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_line_2d(new pcl::PointCloud<pcl::PointXYZ>);
|
|
|
pcl::copyPointCloud(*in_line_cloud, *cloud_line_2d);
|
|
@@ -2807,7 +2808,8 @@ void CRootStockGrabPoint::line_filter(
|
|
|
float mean_r = 0.0;
|
|
|
float cnt = 0.0;
|
|
|
for (auto&r : stem_diameters) {
|
|
|
- if (r > 0.0) {
|
|
|
+ if (r > 0.5) {
|
|
|
+ //边缘点有可能被遗漏造成半径很小,将很小的半径去除(即小于直径1.0的苗,认为是异常,剔除异常数据)
|
|
|
mean_r += r;
|
|
|
cnt += 1.0;
|
|
|
}
|
|
@@ -2815,6 +2817,10 @@ void CRootStockGrabPoint::line_filter(
|
|
|
if (cnt > 0.0) {
|
|
|
mean_r /= cnt;
|
|
|
}
|
|
|
+ std::vector<float> stem_diameters_cpy(stem_diameters);
|
|
|
+ std::sort(stem_diameters_cpy.begin(),stem_diameters_cpy.end());
|
|
|
+ int idx80 = int(0.8*stem_diameters_cpy.size());
|
|
|
+ stem_width_mu = 2.0 * stem_diameters_cpy.at(idx80);
|
|
|
|
|
|
int del_radius = 4;
|
|
|
int security_r = (int)(stemd / 2.0 + 0.5);//保护半径
|
|
@@ -2859,7 +2865,7 @@ void CRootStockGrabPoint::line_filter(
|
|
|
while (true) {
|
|
|
//找到最大值的位置和最大值
|
|
|
int midx = max_element(stem_width_ex_cp.begin(), stem_width_ex_cp.end()) - stem_width_ex_cp.begin();
|
|
|
- if (stem_width_ex_cp.at(midx) > th_fork * stem_width_mu) {
|
|
|
+ if (stem_width_ex_cp.at(midx) > th_fork * stem_width_ex_mu) {
|
|
|
//检测fork_pos中的近邻是否存在
|
|
|
bool has_nn = false;
|
|
|
for (auto& fy : fork_pos) {
|