10 #include <unordered_map>
46 const double* intrinsic_ptr = intrinsics.
GetDataPtr<
double>();
47 const double* extrinsic_ptr = extrinsics.
GetDataPtr<
double>();
48 for (
int i = 0; i < 3; ++i) {
49 for (
int j = 0; j < 4; ++j) {
50 extrinsic_[i][j] = extrinsic_ptr[i * 4 + j];
54 fx_ = intrinsic_ptr[0 * 3 + 0];
55 fy_ = intrinsic_ptr[1 * 3 + 1];
56 cx_ = intrinsic_ptr[0 * 3 + 2];
57 cy_ = intrinsic_ptr[1 * 3 + 2];
72 *x_out = x_in * extrinsic_[0][0] + y_in * extrinsic_[0][1] +
73 z_in * extrinsic_[0][2] + extrinsic_[0][3];
74 *y_out = x_in * extrinsic_[1][0] + y_in * extrinsic_[1][1] +
75 z_in * extrinsic_[1][2] + extrinsic_[1][3];
76 *z_out = x_in * extrinsic_[2][0] + y_in * extrinsic_[2][1] +
77 z_in * extrinsic_[2][2] + extrinsic_[2][3];
91 *x_out = x_in * extrinsic_[0][0] + y_in * extrinsic_[0][1] +
92 z_in * extrinsic_[0][2];
93 *y_out = x_in * extrinsic_[1][0] + y_in * extrinsic_[1][1] +
94 z_in * extrinsic_[1][2];
95 *z_out = x_in * extrinsic_[2][0] + y_in * extrinsic_[2][1] +
96 z_in * extrinsic_[2][2];
104 float* v_out)
const {
105 float inv_z = 1.0f / z_in;
106 *u_out = fx_ * x_in * inv_z + cx_;
107 *v_out = fy_ * y_in * inv_z + cy_;
116 float* z_out)
const {
117 *x_out = (u_in - cx_) * d_in / fx_;
118 *y_out = (v_in - cy_) * d_in / fy_;
130 *x = extrinsic_[0][3];
131 *y = extrinsic_[1][3];
132 *z = extrinsic_[2][3];
136 float extrinsic_[3][4];
160 template <
typename index_t>
172 "Only support contiguous tensors for general operations.");
179 "Tensor shape too large, only <= {} and <= {} array dim is "
180 "supported, but received {}.",
185 active_dims_ = active_dims;
186 for (
index_t i = 0; i < active_dims_; ++i) {
187 shape_[i] = shape[i];
191 for (
index_t i = active_dims_; i < n; ++i) {
192 element_byte_size_ *= shape[i];
199 ptr_ =
const_cast<void*
>(ndarray.
GetDataPtr());
207 "SizeVector too large, only <= {} is supported, but "
212 for (
index_t i = 0; i < active_dims_; ++i) {
213 shape_[i] = shape[i];
222 element_byte_size_ = 0;
230 for (
index_t i = 0; i < active_dims_; ++i) {
231 num_elems *= shape_[i];
240 *workload = y_in * shape_[1] + x_in;
248 *workload = (z_in * shape_[1] + y_in) * shape_[2] + x_in;
257 *workload = ((t_in * shape_[1] + z_in) * shape_[2] + y_in) * shape_[3] +
265 *x_out = workload % shape_[1];
266 *y_out = workload / shape_[1];
274 *x_out = workload % shape_[2];
275 workload = (workload - *x_out) / shape_[2];
276 *y_out = workload % shape_[1];
277 *z_out = workload / shape_[1];
286 *x_out = workload % shape_[3];
287 workload = (workload - *x_out) / shape_[3];
288 *y_out = workload % shape_[2];
289 workload = (workload - *y_out) / shape_[2];
290 *z_out = workload % shape_[1];
291 *t_out = workload / shape_[1];
295 return y >= 0 && x >= 0 && y <= shape_[0] - 1.0f &&
296 x <= shape_[1] - 1.0f;
299 return z >= 0 && y >= 0 && x >= 0 && z <= shape_[0] - 1.0f &&
300 y <= shape_[1] - 1.0f && x <= shape_[2] - 1.0f;
306 return t >= 0 && z >= 0 && y >= 0 && x >= 0 && t <= shape_[0] - 1.0f &&
307 z <= shape_[1] - 1.0f && y <= shape_[2] - 1.0f &&
308 x <= shape_[3] - 1.0f;
317 template <
typename T>
319 return static_cast<T*
>(
static_cast<void*
>(
static_cast<uint8_t*
>(ptr_) +
320 x * element_byte_size_));
323 template <
typename T>
327 return static_cast<T*
>(
static_cast<void*
>(
328 static_cast<uint8_t*
>(ptr_) + workload * element_byte_size_));
331 template <
typename T>
337 return static_cast<T*
>(
static_cast<void*
>(
338 static_cast<uint8_t*
>(ptr_) + workload * element_byte_size_));
341 template <
typename T>
348 return static_cast<T*
>(
static_cast<void*
>(
349 static_cast<uint8_t*
>(ptr_) + workload * element_byte_size_));
#define OPEN3D_HOST_DEVICE
Definition: CUDAUtils.h:44
#define LogError(...)
Definition: Logging.h:48
#define AssertTensorDevice(tensor,...)
Definition: TensorCheck.h:43
#define AssertTensorDtype(tensor,...)
Definition: TensorCheck.h:21
#define AssertTensorShape(tensor,...)
Definition: TensorCheck.h:58
int64_t ByteSize() const
Definition: Dtype.h:58
Definition: SizeVector.h:69
size_t size() const
Definition: SmallVector.h:119
T * GetDataPtr()
Definition: Tensor.h:1143
SizeVector GetShape() const
Definition: Tensor.h:1126
int64_t NumDims() const
Definition: Tensor.h:1171
bool IsContiguous() const
Definition: Tensor.h:1035
Dtype GetDtype() const
Definition: Tensor.h:1163
Definition: GeometryIndexer.h:161
OPEN3D_HOST_DEVICE void WorkloadToCoord(index_t workload, index_t *x_out, index_t *y_out, index_t *z_out, index_t *t_out) const
Workload => 4D coordinate.
Definition: GeometryIndexer.h:281
OPEN3D_HOST_DEVICE bool InBoundary(float x, float y) const
Definition: GeometryIndexer.h:294
TArrayIndexer()
Definition: GeometryIndexer.h:163
OPEN3D_HOST_DEVICE void CoordToWorkload(index_t x_in, index_t y_in, index_t z_in, index_t t_in, index_t *workload) const
4D coordinate => workload
Definition: GeometryIndexer.h:252
TArrayIndexer(const core::Tensor &ndarray, index_t active_dims)
Definition: GeometryIndexer.h:169
OPEN3D_HOST_DEVICE void CoordToWorkload(index_t x_in, index_t y_in, index_t *workload) const
2D coordinate => workload
Definition: GeometryIndexer.h:237
OPEN3D_HOST_DEVICE void WorkloadToCoord(index_t workload, index_t *x_out, index_t *y_out) const
Workload => 2D coordinate.
Definition: GeometryIndexer.h:262
OPEN3D_HOST_DEVICE T * GetDataPtr(index_t x, index_t y, index_t z, index_t t) const
Definition: GeometryIndexer.h:342
OPEN3D_HOST_DEVICE void * GetDataPtr() const
Definition: GeometryIndexer.h:315
OPEN3D_HOST_DEVICE index_t ElementByteSize()
Definition: GeometryIndexer.h:226
OPEN3D_HOST_DEVICE T * GetDataPtr(index_t x, index_t y) const
Definition: GeometryIndexer.h:324
OPEN3D_HOST_DEVICE bool InBoundary(float x, float y, float z) const
Definition: GeometryIndexer.h:298
OPEN3D_HOST_DEVICE void CoordToWorkload(index_t x_in, index_t y_in, index_t z_in, index_t *workload) const
3D coordinate => workload
Definition: GeometryIndexer.h:244
OPEN3D_HOST_DEVICE index_t GetShape(int i) const
Definition: GeometryIndexer.h:311
OPEN3D_HOST_DEVICE index_t NumElements()
Definition: GeometryIndexer.h:228
OPEN3D_HOST_DEVICE T * GetDataPtr(index_t x, index_t y, index_t z) const
Definition: GeometryIndexer.h:332
OPEN3D_HOST_DEVICE bool InBoundary(float x, float y, float z, float t) const
Definition: GeometryIndexer.h:302
OPEN3D_HOST_DEVICE T * GetDataPtr(index_t x) const
Definition: GeometryIndexer.h:318
OPEN3D_HOST_DEVICE void WorkloadToCoord(index_t workload, index_t *x_out, index_t *y_out, index_t *z_out) const
Workload => 3D coordinate.
Definition: GeometryIndexer.h:270
TArrayIndexer(const core::SizeVector &shape)
Only used for simple shapes.
Definition: GeometryIndexer.h:203
const Dtype Float64
Definition: Dtype.cpp:43
int index_t
Definition: VoxelBlockGrid.h:22
const int64_t MAX_RESOLUTION_DIMS
Definition: GeometryIndexer.h:158
Definition: PinholeCameraIntrinsic.cpp:16