-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjustments to https://github.com/GabijaBern/raycloudtools/tree/new_command_line_params #24
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ TreesParams::TreesParams() | |
, crop_length(1.0) | ||
, distance_limit(1.0) | ||
, height_min(2.0) | ||
, radius_min(0.0) | ||
, girth_height_ratio(0.12) | ||
, cylinder_length_to_width(4.0) | ||
, gap_ratio(0.016) | ||
|
@@ -23,6 +24,7 @@ TreesParams::TreesParams() | |
, segment_branches(false) | ||
, global_taper(0.012) | ||
, global_taper_factor(0.3) | ||
, grid_origin(0,0) | ||
{} | ||
|
||
/// The main reconstruction algorithm | ||
|
@@ -283,6 +285,10 @@ Trees::Trees(Cloud &cloud, const Eigen::Vector3d &offset, const Mesh &mesh, cons | |
removeOutOfBoundSections(cloud, min_bound, max_bound, offset); | ||
} | ||
|
||
if (params_->radius_min > 0.0) | ||
{ | ||
removeSmallRadiusTrees(); | ||
} | ||
std::vector<int> root_segs(cloud.ends.size(), -1); | ||
// now colour the ray cloud based on the segmentation | ||
segmentCloud(cloud, root_segs, section_ids); | ||
|
@@ -1051,11 +1057,14 @@ void Trees::removeOutOfBoundSections(const Cloud &cloud, Eigen::Vector3d &min_bo | |
const double width = params_->grid_width; | ||
cloud.calcBounds(&min_bound, &max_bound); | ||
const Eigen::Vector3d mid = (min_bound + max_bound)/2.0 + offset; | ||
const Eigen::Vector2d inds(std::round(mid[0] / width), std::round(mid[1] / width)); | ||
min_bound[0] = width * (inds[0] - 0.5) - offset[0]; | ||
min_bound[1] = width * (inds[1] - 0.5) - offset[1]; | ||
max_bound[0] = width * (inds[0] + 0.5) - offset[0]; | ||
max_bound[1] = width * (inds[1] + 0.5) - offset[1]; | ||
Eigen::Vector2d mid_local(mid[0], mid[1]); | ||
mid_local -= params_->grid_origin; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And shouldn't this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically it is: grid_origin + snap_to_grid(mid - grid_origin) The '-d' treads on the distance_limit param, so I had to change it to -j in my PR. One reason why I like to minimise command line parameters. |
||
const Eigen::Vector2d inds(std::floor(mid_local[0] / width), std::floor(mid_local[1] / width)); | ||
min_bound[0] = width * (inds[0]) + params_->grid_origin[0] - offset[0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I am understanding your implementation correctly, you don't need to add the params_->grid_origin[0], for subsequent calls as well, otherwise, you remove the grid origin shift? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically it is: grid_origin + snap_to_grid(mid - grid_origin) |
||
min_bound[1] = width * (inds[1]) + params_->grid_origin[1] - offset[1]; | ||
max_bound[0] = width * (inds[0] + 1.0) + params_->grid_origin[0] - offset[0]; | ||
max_bound[1] = width * (inds[1] + 1.0) + params_->grid_origin[1] - offset[1]; | ||
|
||
std::cout << "min bound: " << (min_bound+offset).transpose() << ", max bound: " << (max_bound+offset).transpose() << std::endl; | ||
|
||
// disable trees out of bounds | ||
|
@@ -1073,6 +1082,22 @@ void Trees::removeOutOfBoundSections(const Cloud &cloud, Eigen::Vector3d &min_bo | |
} | ||
} | ||
|
||
// filtering out these smaller trees must be done at the end, as that is when we have a final estimation of global taper (and therefore radius) | ||
void Trees::removeSmallRadiusTrees() | ||
{ | ||
for (auto §ion : sections_) | ||
{ | ||
if (section.parent >= 0 || section.children.empty()) | ||
{ | ||
continue; | ||
} | ||
if (radius(section) < params_->radius_min) | ||
{ | ||
section.children.clear(); // make it a non-tree | ||
} | ||
} | ||
} | ||
|
||
// colour the cloud by tree id, or by branch segment id | ||
void Trees::segmentCloud(Cloud &cloud, std::vector<int> &root_segs, const std::vector<int> §ion_ids) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ bool readLas(const std::string &file_name, | |
|
||
if (ifs.fail()) | ||
{ | ||
std::cerr << "readLas: failed to open stream" << std::endl; | ||
std::cerr << "readLas: failed to open file " << file_name << ", error: " << std::strerror(errno) << std::endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not certain this error will inform if file does not exist. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does. Just tested it. |
||
return false; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious to understand the code a little bit better. If I run this approach, will it break the algorithm? What does bifurcate() method do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removeSmallRadiusTrees() is called towards the end when the radius() function will be accurate. We can't filter based on estimated_radius because this is not the final estimation, just an initial estimate.
bifurcate() is a function for splitting a segment at a tree branching point, so it adds to segments (cylinders) to the list, the key line being: sections_.push_back(new_node); Usually it is just a split in two, but it may also split into multiple branches.