-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add compute bounding box member method #3970
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
Open
truhoang
wants to merge
13
commits into
PointCloudLibrary:master
Choose a base branch
from
truhoang:refactor-eigen
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ab728a1
Add compute bounding box member method
truhoang 0dc36ce
Refactor position coordinates with Eigen vectors
truhoang 54452ab
Use eigen interface to access point's coordinates
truhoang ec1adc6
Change function interface and remove auto
truhoang 7c9940e
Change function name
truhoang 999d30f
Use eigen min/max functions
truhoang 593be52
Fix Eigen min/ma assignment
truhoang 7db6764
Clean up for-loops and remove redundancies
truhoang 614a1dd
Replace vector3f with vector4f
truhoang 9a53321
Merge branch 'master' into refactor-eigen
truhoang e5d5533
Empty commit to start CI
truhoang 18c4f75
Merge branch 'refactor-eigen' of ssh://github.com/truhoang/pcl into r…
truhoang fd9b041
Fix eigen vector type bug
truhoang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,72 +150,79 @@ LineRGBD<PointXYZT, PointRGBT>::loadTemplates (const std::string &file_name, con | |
|
||
// Compute 3D bounding boxes from the template point clouds | ||
bounding_boxes_.resize (template_point_clouds_.size ()); | ||
for (std::size_t i = 0; i < template_point_clouds_.size (); ++i) | ||
for (std::size_t i = 0; i < template_point_clouds_.size (); ++i) | ||
{ | ||
PointCloud<PointXYZRGBA> & template_point_cloud = template_point_clouds_[i]; | ||
BoundingBoxXYZ & bb = bounding_boxes_[i]; | ||
bb.x = bb.y = bb.z = std::numeric_limits<float>::max (); | ||
bb.width = bb.height = bb.depth = 0.0f; | ||
computeBoundingBox (i); | ||
} | ||
|
||
float center_x = 0.0f; | ||
float center_y = 0.0f; | ||
float center_z = 0.0f; | ||
float min_x = std::numeric_limits<float>::max (); | ||
float min_y = std::numeric_limits<float>::max (); | ||
float min_z = std::numeric_limits<float>::max (); | ||
float max_x = -std::numeric_limits<float>::max (); | ||
float max_y = -std::numeric_limits<float>::max (); | ||
float max_z = -std::numeric_limits<float>::max (); | ||
std::size_t counter = 0; | ||
for (std::size_t j = 0; j < template_point_cloud.size (); ++j) | ||
{ | ||
const PointXYZRGBA & p = template_point_cloud.points[j]; | ||
return (true); | ||
} | ||
|
||
if (!std::isfinite (p.x) || !std::isfinite (p.y) || !std::isfinite (p.z)) | ||
continue; | ||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
template <typename PointXYZT, typename PointRGBT> void | ||
truhoang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pcl::LineRGBD<PointXYZT, PointRGBT>::computeBoundingBox (int i) | ||
{ | ||
PointCloud<PointXYZRGBA> & template_point_cloud = template_point_clouds_[i]; | ||
BoundingBoxXYZ & bb = bounding_boxes_[i]; | ||
bb.x = bb.y = bb.z = std::numeric_limits<float>::max (); | ||
bb.width = bb.height = bb.depth = 0.0f; | ||
truhoang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
float center_x = 0.0f; | ||
truhoang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
float center_y = 0.0f; | ||
float center_z = 0.0f; | ||
float min_x = std::numeric_limits<float>::max (); | ||
float min_y = std::numeric_limits<float>::max (); | ||
float min_z = std::numeric_limits<float>::max (); | ||
float max_x = -std::numeric_limits<float>::max (); | ||
float max_y = -std::numeric_limits<float>::max (); | ||
float max_z = -std::numeric_limits<float>::max (); | ||
std::size_t counter = 0; | ||
for (std::size_t j = 0; j < template_point_cloud.size (); ++j) | ||
truhoang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
const PointXYZRGBA & p = template_point_cloud.points[j]; | ||
|
||
min_x = std::min (min_x, p.x); | ||
min_y = std::min (min_y, p.y); | ||
min_z = std::min (min_z, p.z); | ||
max_x = std::max (max_x, p.x); | ||
max_y = std::max (max_y, p.y); | ||
max_z = std::max (max_z, p.z); | ||
if (!std::isfinite (p.x) || !std::isfinite (p.y) || !std::isfinite (p.z)) | ||
truhoang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
continue; | ||
|
||
center_x += p.x; | ||
center_y += p.y; | ||
center_z += p.z; | ||
min_x = std::min (min_x, p.x); | ||
min_y = std::min (min_y, p.y); | ||
min_z = std::min (min_z, p.z); | ||
max_x = std::max (max_x, p.x); | ||
max_y = std::max (max_y, p.y); | ||
max_z = std::max (max_z, p.z); | ||
|
||
++counter; | ||
} | ||
center_x += p.x; | ||
center_y += p.y; | ||
center_z += p.z; | ||
|
||
center_x /= static_cast<float> (counter); | ||
center_y /= static_cast<float> (counter); | ||
center_z /= static_cast<float> (counter); | ||
++counter; | ||
} | ||
|
||
bb.width = max_x - min_x; | ||
bb.height = max_y - min_y; | ||
bb.depth = max_z - min_z; | ||
center_x /= static_cast<float> (counter); | ||
center_y /= static_cast<float> (counter); | ||
center_z /= static_cast<float> (counter); | ||
|
||
bb.x = (min_x + bb.width / 2.0f) - center_x - bb.width / 2.0f; | ||
bb.y = (min_y + bb.height / 2.0f) - center_y - bb.height / 2.0f; | ||
bb.z = (min_z + bb.depth / 2.0f) - center_z - bb.depth / 2.0f; | ||
Comment on lines
-199
to
-201
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'm embarrassed this exists in our code base. |
||
bb.width = max_x - min_x; | ||
bb.height = max_y - min_y; | ||
bb.depth = max_z - min_z; | ||
|
||
for (std::size_t j = 0; j < template_point_cloud.size (); ++j) | ||
{ | ||
PointXYZRGBA p = template_point_cloud.points[j]; | ||
bb.x = (min_x + bb.width / 2.0f) - center_x - bb.width / 2.0f; | ||
bb.y = (min_y + bb.height / 2.0f) - center_y - bb.height / 2.0f; | ||
bb.z = (min_z + bb.depth / 2.0f) - center_z - bb.depth / 2.0f; | ||
|
||
if (!std::isfinite (p.x) || !std::isfinite (p.y) || !std::isfinite (p.z)) | ||
continue; | ||
for (std::size_t j = 0; j < template_point_cloud.size (); ++j) | ||
{ | ||
PointXYZRGBA p = template_point_cloud.points[j]; | ||
|
||
p.x -= center_x; | ||
p.y -= center_y; | ||
p.z -= center_z; | ||
if (!std::isfinite (p.x) || !std::isfinite (p.y) || !std::isfinite (p.z)) | ||
continue; | ||
|
||
template_point_cloud.points[j] = p; | ||
} | ||
} | ||
p.x -= center_x; | ||
p.y -= center_y; | ||
p.z -= center_z; | ||
|
||
return (true); | ||
template_point_cloud.points[j] = p; | ||
} | ||
} | ||
|
||
|
||
|
@@ -238,68 +245,7 @@ LineRGBD<PointXYZT, PointRGBT>::createAndAddTemplate ( | |
bounding_boxes_.resize (template_point_clouds_.size ()); | ||
{ | ||
const std::size_t i = template_point_clouds_.size () - 1; | ||
|
||
PointCloud<PointXYZRGBA> & template_point_cloud = template_point_clouds_[i]; | ||
BoundingBoxXYZ & bb = bounding_boxes_[i]; | ||
bb.x = bb.y = bb.z = std::numeric_limits<float>::max (); | ||
bb.width = bb.height = bb.depth = 0.0f; | ||
|
||
float center_x = 0.0f; | ||
float center_y = 0.0f; | ||
float center_z = 0.0f; | ||
float min_x = std::numeric_limits<float>::max (); | ||
float min_y = std::numeric_limits<float>::max (); | ||
float min_z = std::numeric_limits<float>::max (); | ||
float max_x = -std::numeric_limits<float>::max (); | ||
float max_y = -std::numeric_limits<float>::max (); | ||
float max_z = -std::numeric_limits<float>::max (); | ||
std::size_t counter = 0; | ||
for (std::size_t j = 0; j < template_point_cloud.size (); ++j) | ||
{ | ||
const PointXYZRGBA & p = template_point_cloud.points[j]; | ||
|
||
if (!std::isfinite (p.x) || !std::isfinite (p.y) || !std::isfinite (p.z)) | ||
continue; | ||
|
||
min_x = std::min (min_x, p.x); | ||
min_y = std::min (min_y, p.y); | ||
min_z = std::min (min_z, p.z); | ||
max_x = std::max (max_x, p.x); | ||
max_y = std::max (max_y, p.y); | ||
max_z = std::max (max_z, p.z); | ||
|
||
center_x += p.x; | ||
center_y += p.y; | ||
center_z += p.z; | ||
|
||
++counter; | ||
} | ||
|
||
center_x /= static_cast<float> (counter); | ||
center_y /= static_cast<float> (counter); | ||
center_z /= static_cast<float> (counter); | ||
|
||
bb.width = max_x - min_x; | ||
bb.height = max_y - min_y; | ||
bb.depth = max_z - min_z; | ||
|
||
bb.x = (min_x + bb.width / 2.0f) - center_x - bb.width / 2.0f; | ||
bb.y = (min_y + bb.height / 2.0f) - center_y - bb.height / 2.0f; | ||
bb.z = (min_z + bb.depth / 2.0f) - center_z - bb.depth / 2.0f; | ||
|
||
for (std::size_t j = 0; j < template_point_cloud.size (); ++j) | ||
{ | ||
PointXYZRGBA p = template_point_cloud.points[j]; | ||
|
||
if (!std::isfinite (p.x) || !std::isfinite (p.y) || !std::isfinite (p.z)) | ||
continue; | ||
|
||
p.x -= center_x; | ||
p.y -= center_y; | ||
p.z -= center_z; | ||
|
||
template_point_cloud.points[j] = p; | ||
} | ||
computeBoundingBox (i); | ||
} | ||
|
||
std::vector<pcl::QuantizableModality*> modalities; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,6 +282,10 @@ namespace pcl | |
bool | ||
readLTMHeader (int fd, pcl::io::TARHeader &header); | ||
|
||
/** \brief Compute bounding box from PCD masks **/ | ||
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. Missing parameter description |
||
void | ||
computeBoundingBox (int i); | ||
|
||
/** \brief Intersection volume threshold. */ | ||
float intersection_volume_threshold_; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.