45 void ClipTransformCUDA
59 int64_t cols = dst.GetShape(1);
60 int64_t n = rows * cols;
65 int64_t y = workload_idx / cols;
66 int64_t x = workload_idx % cols;
68 float in =
static_cast<float>(
70 float out = in / scale;
71 out = out <= min_value ? clip_fill : out;
72 out = out >= max_value ? clip_fill : out;
95 int rows_down = dst_indexer.
GetShape(0);
96 int cols_down = dst_indexer.
GetShape(1);
97 int n = rows_down * cols_down;
101 const int gkernel_size = 5;
102 const int gkernel_size_2 = gkernel_size / 2;
103 const float gweights[3] = {0.375f, 0.25f, 0.0625f};
113 int y = workload_idx / cols_down;
114 int x = workload_idx % cols_down;
119 float v_center = *src_indexer.
GetDataPtr<
float>(x_src, y_src);
120 if (v_center == invalid_fill) {
121 *dst_indexer.
GetDataPtr<
float>(x, y) = invalid_fill;
125 int x_min = max(0, x_src - gkernel_size_2);
126 int y_min = max(0, y_src - gkernel_size_2);
128 int x_max = min(cols - 1, x_src + gkernel_size_2);
129 int y_max = min(rows - 1, y_src + gkernel_size_2);
133 for (
int yk = y_min; yk <= y_max; ++yk) {
134 for (
int xk = x_min; xk <= x_max; ++xk) {
135 float v = *src_indexer.
GetDataPtr<
float>(xk, yk);
136 int dy = abs(yk - y_src);
137 int dx = abs(xk - x_src);
139 if (v != invalid_fill &&
140 abs(v - v_center) < depth_diff) {
141 float w = gweights[dx] * gweights[dy];
149 w_sum == 0 ? invalid_fill : v_sum / w_sum;
154 void CreateVertexMapCUDA
161 float invalid_fill) {
169 int64_t n = rows * cols;
179 if (isinf(invalid_fill))
return isinf(v);
180 if (isnan(invalid_fill))
return isnan(v);
181 return v == invalid_fill;
184 int64_t y = workload_idx / cols;
185 int64_t x = workload_idx % cols;
187 float d = *src_indexer.
GetDataPtr<
float>(x, y);
189 float* vertex = dst_indexer.
GetDataPtr<
float>(x, y);
190 if (!is_invalid(d)) {
191 ti.
Unproject(static_cast<float>(x), static_cast<float>(y),
192 d, vertex + 0, vertex + 1, vertex + 2);
194 vertex[0] = invalid_fill;
195 vertex[1] = invalid_fill;
196 vertex[2] = invalid_fill;
201 void CreateNormalMapCUDA
209 int64_t rows = src_indexer.
GetShape(0);
210 int64_t cols = src_indexer.
GetShape(1);
211 int64_t n = rows * cols;
215 int64_t y = workload_idx / cols;
216 int64_t x = workload_idx % cols;
218 float* normal = dst_indexer.
GetDataPtr<
float>(x, y);
220 if (y < rows - 1 && x < cols - 1) {
221 float* v00 = src_indexer.
GetDataPtr<
float>(x, y);
222 float* v10 = src_indexer.
GetDataPtr<
float>(x + 1, y);
223 float* v01 = src_indexer.
GetDataPtr<
float>(x, y + 1);
225 if ((v00[0] == invalid_fill && v00[1] == invalid_fill &&
226 v00[2] == invalid_fill) ||
227 (v01[0] == invalid_fill && v01[1] == invalid_fill &&
228 v01[2] == invalid_fill) ||
229 (v10[0] == invalid_fill && v10[1] == invalid_fill &&
230 v10[2] == invalid_fill)) {
231 normal[0] = invalid_fill;
232 normal[1] = invalid_fill;
233 normal[2] = invalid_fill;
237 float dx0 = v01[0] - v00[0];
238 float dy0 = v01[1] - v00[1];
239 float dz0 = v01[2] - v00[2];
241 float dx1 = v10[0] - v00[0];
242 float dy1 = v10[1] - v00[1];
243 float dz1 = v10[2] - v00[2];
245 normal[0] = dy0 * dz1 - dz0 * dy1;
246 normal[1] = dz0 * dx1 - dx0 * dz1;
247 normal[2] = dx0 * dy1 - dy0 * dx1;
250 sqrt(normal[0] * normal[0] + normal[1] * normal[1] +
251 normal[2] * normal[2]);
252 normal[0] /= normal_norm;
253 normal[1] /= normal_norm;
254 normal[2] /= normal_norm;
256 normal[0] = invalid_fill;
257 normal[1] = invalid_fill;
258 normal[2] = invalid_fill;
264 void ColorizeDepthCUDA
277 int64_t cols = dst.GetShape(1);
278 int64_t n = rows * cols;
280 float inv_interval = 255.0f / (max_value -
min_value);
284 int64_t y = workload_idx / cols;
285 int64_t x = workload_idx % cols;
287 float in =
static_cast<float>(
289 float out = in / scale;
290 out = out <= min_value ?
min_value : out;
291 out = out >= max_value ?
max_value : out;
294 static_cast<int>(inv_interval * (out -
min_value));
295 uint8_t* out_ptr = dst_indexer.
GetDataPtr<uint8_t>(x, y);
296 out_ptr[0] = turbo_srgb_bytes[idx][0];
297 out_ptr[1] = turbo_srgb_bytes[idx][1];
298 out_ptr[2] = turbo_srgb_bytes[idx][2];
OPEN3D_HOST_DEVICE index_t GetShape(int i) const
Definition: GeometryIndexer.h:331
Definition: GeometryIndexer.h:180
OPEN3D_HOST_DEVICE void * GetDataPtr() const
Definition: GeometryIndexer.h:335
void ColorizeDepthCPU(const core::Tensor &src, core::Tensor &dst, float scale, float min_value, float max_value)
Definition: ImageImpl.h:268
void ParallelFor(const Device &device, int64_t n, const func_t &func)
Definition: ParallelFor.h:122
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle image_handle timestamp_usec white_balance image_handle k4a_device_configuration_t config device_handle char size_t serial_number_size bool int32_t int32_t max_value
Definition: K4aPlugin.cpp:648
Device GetDevice() const
Definition: Tensor.cpp:1365
Dtype GetDtype() const
Definition: Tensor.h:1094
#define OPEN3D_DEVICE
Definition: CUDAUtils.h:64
void PyrDownDepthCPU(const core::Tensor &src, core::Tensor &dst, float diff_threshold, float invalid_fill)
Definition: ImageImpl.h:85
void CreateVertexMapCPU(const core::Tensor &src, core::Tensor &dst, const core::Tensor &intrinsics, float invalid_fill)
Definition: ImageImpl.h:158
void ClipTransformCPU(const core::Tensor &src, core::Tensor &dst, float scale, float min_value, float max_value, float clip_fill=0.0f)
Definition: ImageImpl.h:49
SizeVector GetShape() const
Definition: Tensor.h:1057
#define DISPATCH_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition: Dispatch.h:49
Definition: PinholeCameraIntrinsic.cpp:35
void CreateNormalMapCPU(const core::Tensor &src, core::Tensor &dst, float invalid_fill)
Definition: ImageImpl.h:205
const Dtype Float64
Definition: Dtype.cpp:62
static Tensor Eye(int64_t n, Dtype dtype, const Device &device)
Create an identity matrix of size n x n.
Definition: Tensor.cpp:392
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle image_handle timestamp_usec white_balance image_handle k4a_device_configuration_t config device_handle char size_t serial_number_size bool int32_t min_value
Definition: K4aPlugin.cpp:648
std::shared_ptr< core::Tensor > image
Definition: FilamentRenderer.cpp:228