Skip to content

Commit

Permalink
Create albedo texture for a model from calibrated images (#6806)
Browse files Browse the repository at this point in the history
Create an albedo for the triangle mesh using calibrated images. The triangle mesh must have texture coordinates (texture_uvs triangle attribute). This works by back projecting the images onto the texture surface. Overlapping images are 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.
  • Loading branch information
ssheorey authored Jan 1, 2025
1 parent d251815 commit e920e22
Show file tree
Hide file tree
Showing 21 changed files with 742 additions and 57 deletions.
4 changes: 2 additions & 2 deletions cpp/open3d/core/TensorKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ class TensorKey {
/// For TensorKeyMode::Slice only.
int64_t GetStart() const;

/// Get stop index. Throws exception if start is None.
/// Get stop index. Throws exception if stop is None.
/// For TensorKeyMode::Slice only.
int64_t GetStop() const;

/// Get step index. Throws exception if start is None.
/// Get step index. Throws exception if step is None.
/// For TensorKeyMode::Slice only.
int64_t GetStep() const;

Expand Down
3 changes: 2 additions & 1 deletion cpp/open3d/io/ImageIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ bool WriteImage(const std::string &filename,
auto map_itr = file_extension_to_image_write_function.find(filename_ext);
if (map_itr == file_extension_to_image_write_function.end()) {
utility::LogWarning(
"Write geometry::Image failed: unknown file extension.");
"Write geometry::Image failed: file extension {} unknown.",
filename_ext);
return false;
}
return map_itr->second(filename, image, quality);
Expand Down
6 changes: 6 additions & 0 deletions cpp/open3d/t/geometry/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ Image Image::Resize(float sampling_rate, InterpType interp_type) const {
if (sampling_rate == 1.0f) {
return *this;
}
if (GetDtype() == core::Bool) { // Resize via UInt8
return Image(Image(data_.ReinterpretCast(core::UInt8))
.Resize(sampling_rate, interp_type)
.AsTensor()
.ReinterpretCast(core::Bool));
}

static const dtype_channels_pairs npp_supported{
{core::UInt8, 1}, {core::UInt16, 1}, {core::Float32, 1},
Expand Down
3 changes: 1 addition & 2 deletions cpp/open3d/t/geometry/RaycastingScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ uint32_t RaycastingScene::AddTriangles(const TriangleMesh& mesh) {
}

std::unordered_map<std::string, core::Tensor> RaycastingScene::CastRays(
const core::Tensor& rays, const int nthreads) {
const core::Tensor& rays, const int nthreads) const {
AssertTensorDtypeLastDimDeviceMinNDim<float>(rays, "rays", 6,
impl_->tensor_device_);
auto shape = rays.GetShape();
Expand Down Expand Up @@ -1723,7 +1723,6 @@ uint32_t RaycastingScene::INVALID_ID() { return RTC_INVALID_GEOMETRY_ID; }
} // namespace geometry
} // namespace t
} // namespace open3d

namespace fmt {
template <>
struct formatter<RTCError> {
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/t/geometry/RaycastingScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class RaycastingScene {
/// - \b primitive_normals A tensor with the normals of the hit
/// triangles. The shape is {.., 3}.
std::unordered_map<std::string, core::Tensor> CastRays(
const core::Tensor &rays, const int nthreads = 0);
const core::Tensor &rays, const int nthreads = 0) const;

/// \brief Checks if the rays have any intersection with the scene.
/// \param rays A tensor with >=2 dims, shape {.., 6}, and Dtype Float32
Expand Down
Loading

0 comments on commit e920e22

Please sign in to comment.