-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add Tensor OBB #5389
Add Tensor OBB #5389
Conversation
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes. |
…into yueci/tensor-obb
Enable type casting to part of both aabb and obb functions (eg. |
@@ -30,6 +30,19 @@ | |||
#include "open3d/core/TensorFunction.h" | |||
#include "open3d/t/geometry/kernel/PointCloud.h" | |||
|
|||
namespace { | |||
|
|||
void PrintWarningMessageFromTensor(const std::string &name, |
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 would not recommend having utility functions for warnings/errors. The code is more readable with in-place warning messages. For error it is strongly recommended to have it in place since it prints the line-no., file info. for the error origin.
} | ||
|
||
AxisAlignedBoundingBox &AxisAlignedBoundingBox::Translate( | ||
const core::Tensor &translation, bool relative) { | ||
core::AssertTensorDevice(translation, GetDevice()); | ||
core::AssertTensorShape(translation, {3}); | ||
core::AssertTensorDtype(translation, GetDtype()); | ||
if (translation.GetDtype() != GetDtype()) { | ||
PrintWarningMessageFromTensor("translation", translation.GetDtype(), |
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.
we may restrict the dtype of translation, transformation, rotation, and center to Float32 and Float64, and perform auto-casting without warning.
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.
Skip warning, silently convert.
core::AssertTensorDevice(center_d, GetDevice()); | ||
core::AssertTensorShape(center_d, {3}); | ||
if (center_d.GetDtype() != GetDtype()) { | ||
PrintWarningMessageFromTensor("center", center_d.GetDtype(), |
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.
Skip warning, silently convert.
extent_.GetItem({core::TensorKey::Index(2)}) * 0.5; | ||
|
||
core::Tensor points = core::Tensor::Zeros({8, 3}, GetDtype(), GetDevice()); | ||
points.SetItem(core::TensorKey::Index(0), |
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.
To investigate a cleaner initialization possibility.
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.
@reyanshsolis How about the following way:
const t::geometry::AxisAlignedBoundingBox aabb(GetExtent() * -0.5, GetExtent() * 0.5);
return aabb.GetBoxPoints().Matmul(GetRotation()).Add(GetCenter());
const core::Tensor &translation, bool relative) { | ||
core::AssertTensorDevice(translation, GetDevice()); | ||
core::AssertTensorShape(translation, {3}); | ||
if (translation.GetDtype() != GetDtype()) { |
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.
Skip warning, silently convert.
const utility::optional<core::Tensor> ¢er) { | ||
core::AssertTensorDevice(rotation, GetDevice()); | ||
core::AssertTensorShape(rotation, {3, 3}); | ||
if (rotation.GetDtype() != GetDtype()) { |
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.
Skip warning, silently convert.
const core::Tensor &transformation) { | ||
core::AssertTensorDevice(transformation, GetDevice()); | ||
core::AssertTensorShape(transformation, {4, 4}); | ||
if (transformation.GetDtype() != GetDtype()) { |
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.
Skip warning, silently convert.
Remove the warning message when casting input tensor. |
…into yueci/tensor-obb
I have the same issue building the |
Ok, it's due to missing |
LGTM after CI. |
Summary:
OrientedBoundingBox
in tensor geometry.Scale
andRotate
.This change is