Skip to content

Commit

Permalink
Only run ProjectImagesToAlbedo on CPU
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheorey committed Jan 2, 2025
1 parent ced91d4 commit 19d44e7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cpp/open3d/t/geometry/TriangleMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,10 @@ Image TriangleMesh::ProjectImagesToAlbedo(
const std::vector<core::Tensor> &extrinsic_matrices,
int tex_size /*=1024*/,
bool update_material /*=true*/) {
if (!GetDevice().IsCPU()) {
utility::LogError(
"ProjectImagesToAlbedo is only supported on CPU device.");
}
using core::None;
using tk = core::TensorKey;
constexpr float EPS = 1e-6;
Expand Down Expand Up @@ -1480,7 +1484,7 @@ Image TriangleMesh::ProjectImagesToAlbedo(
tex_size, {"positions"}, 1, 0, false)["positions"];
core::Tensor albedo =
core::Tensor::Zeros({tex_size, tex_size, 4}, core::Float32);
albedo.Slice(2, 3, 4).Fill(EPS); // regularize
albedo.Slice(2, 3, 4).Fill(EPS); // regularize weight
std::mutex albedo_mutex;

RaycastingScene rcs;
Expand Down
2 changes: 2 additions & 0 deletions cpp/open3d/t/geometry/TriangleMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,8 @@ class TriangleMesh : public Geometry, public DrawableGeometry {
/// albedo. For best results, use images captured with exposure and white
/// balance lock to reduce the chance of seams in the output texture.
///
/// This function is only supported on the CPU device.
///
/// \param images vector of images.
/// \param intrinsic_matrices vector of {3,3} intrinsic matrices describing
/// the pinhole camera.
Expand Down
2 changes: 2 additions & 0 deletions cpp/pybind/t/geometry/trianglemesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,8 @@ blended together in the resulting albedo. For best results, use images captured
with exposure and white balance lock to reduce the chance of seams in the output
texture.
This function is only supported on the CPU.
Args:
images (List[open3d.t.geometry.Image]): List of images.
intrinsic_matrices (List[open3d.core.Tensor]): List of (3,3) intrinsic matrices describing
Expand Down
10 changes: 9 additions & 1 deletion cpp/tests/t/geometry/TriangleMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,9 +1361,11 @@ TEST_P(TriangleMeshPermuteDevices, RemoveUnreferencedVertices) {

TEST_P(TriangleMeshPermuteDevices, ProjectImagesToAlbedo) {
using namespace t::geometry;
using ::testing::AnyOf;
using ::testing::ElementsAre;
using ::testing::FloatEq;
core::Device device = GetParam();
if (!device.IsCPU()) GTEST_SKIP() << "Not Implemented!";
TriangleMesh sphere =
TriangleMesh::FromLegacy(*geometry::TriangleMesh::CreateSphere(
1.0, 20, /*create_uv_map=*/true));
Expand Down Expand Up @@ -1405,7 +1407,13 @@ TEST_P(TriangleMeshPermuteDevices, ProjectImagesToAlbedo) {
.To(core::Float32)
.Mean({0, 1})
.ToFlatVector<float>(),
ElementsAre(FloatEq(87.8693), FloatEq(67.538), FloatEq(64.31)));
AnyOf(ElementsAre(FloatEq(87.8693), FloatEq(67.538),
FloatEq(64.31)), // macOS
ElementsAre(FloatEq(87.8758),
FloatEq(67.5518), // Linux / Windows
FloatEq(64.3254)))

);
} // namespace tests

TEST_P(TriangleMeshPermuteDevices, ComputeTriangleAreas) {
Expand Down

0 comments on commit 19d44e7

Please sign in to comment.