45 void ClipTransformCUDA
59 int64_t cols = dst.GetShape(1);
60 int64_t n = rows * cols;
62 #if defined(__CUDACC__) 63 core::kernel::CUDALauncher launcher;
71 int64_t y = workload_idx / cols;
72 int64_t x = workload_idx % cols;
74 float in =
static_cast<float>(
76 float out = in / scale;
77 out = out <= min_value ? clip_fill : out;
78 out = out >= max_value ? clip_fill : out;
101 int rows_down = dst_indexer.
GetShape(0);
102 int cols_down = dst_indexer.
GetShape(1);
103 int n = rows_down * cols_down;
107 const int gkernel_size = 5;
108 const int gkernel_size_2 = gkernel_size / 2;
109 const float gweights[3] = {0.375f, 0.25f, 0.0625f};
111 #if defined(__CUDACC__) 112 core::kernel::CUDALauncher launcher;
121 int y = workload_idx / cols_down;
122 int x = workload_idx % cols_down;
127 float v_center = *src_indexer.
GetDataPtr<
float>(x_src, y_src);
128 if (v_center == invalid_fill) {
129 *dst_indexer.
GetDataPtr<
float>(x, y) = invalid_fill;
133 int x_min =
max(0, x_src - gkernel_size_2);
134 int y_min =
max(0, y_src - gkernel_size_2);
136 int x_max = min(cols - 1, x_src + gkernel_size_2);
137 int y_max = min(rows - 1, y_src + gkernel_size_2);
141 for (
int yk = y_min; yk <= y_max; ++yk) {
142 for (
int xk = x_min; xk <= x_max; ++xk) {
143 float v = *src_indexer.
GetDataPtr<
float>(xk, yk);
144 int dy = abs(yk - y_src);
145 int dx = abs(xk - x_src);
147 if (v != invalid_fill && abs(v - v_center) < depth_diff) {
148 float w = gweights[dx] * gweights[dy];
155 *dst_indexer.
GetDataPtr<
float>(x, y) = v_sum / w_sum;
160 void CreateVertexMapCUDA
167 float invalid_fill) {
175 int64_t n = rows * cols;
177 #if defined(__CUDACC__) 178 core::kernel::CUDALauncher launcher;
186 if (isinf(invalid_fill))
return isinf(v);
187 if (isnan(invalid_fill))
return isnan(v);
188 return v == invalid_fill;
191 int64_t y = workload_idx / cols;
192 int64_t x = workload_idx % cols;
194 float d = *src_indexer.
GetDataPtr<
float>(x, y);
196 float* vertex = dst_indexer.
GetDataPtr<
float>(x, y);
197 if (!is_invalid(d)) {
198 ti.
Unproject(static_cast<float>(x), static_cast<float>(y), d,
199 vertex + 0, vertex + 1, vertex + 2);
201 vertex[0] = invalid_fill;
202 vertex[1] = invalid_fill;
203 vertex[2] = invalid_fill;
208 void CreateNormalMapCUDA
216 int64_t rows = src_indexer.
GetShape(0);
217 int64_t cols = src_indexer.
GetShape(1);
218 int64_t n = rows * cols;
220 #if defined(__CUDACC__) 221 core::kernel::CUDALauncher launcher;
227 int64_t y = workload_idx / cols;
228 int64_t x = workload_idx % cols;
230 float* normal = dst_indexer.
GetDataPtr<
float>(x, y);
232 if (y < rows - 1 && x < cols - 1) {
233 float* v00 = src_indexer.
GetDataPtr<
float>(x, y);
234 float* v10 = src_indexer.
GetDataPtr<
float>(x + 1, y);
235 float* v01 = src_indexer.
GetDataPtr<
float>(x, y + 1);
237 if ((v00[0] == invalid_fill && v00[1] == invalid_fill &&
238 v00[2] == invalid_fill) ||
239 (v01[0] == invalid_fill && v01[1] == invalid_fill &&
240 v01[2] == invalid_fill) ||
241 (v10[0] == invalid_fill && v10[1] == invalid_fill &&
242 v10[2] == invalid_fill)) {
243 normal[0] = invalid_fill;
244 normal[1] = invalid_fill;
245 normal[2] = invalid_fill;
249 float dx0 = v01[0] - v00[0];
250 float dy0 = v01[1] - v00[1];
251 float dz0 = v01[2] - v00[2];
253 float dx1 = v10[0] - v00[0];
254 float dy1 = v10[1] - v00[1];
255 float dz1 = v10[2] - v00[2];
257 normal[0] = dy0 * dz1 - dz0 * dy1;
258 normal[1] = dz0 * dx1 - dx0 * dz1;
259 normal[2] = dx0 * dy1 - dy0 * dx1;
262 sqrt(normal[0] * normal[0] + normal[1] * normal[1] +
263 normal[2] * normal[2]);
264 normal[0] /= normal_norm;
265 normal[1] /= normal_norm;
266 normal[2] /= normal_norm;
268 normal[0] = invalid_fill;
269 normal[1] = invalid_fill;
270 normal[2] = invalid_fill;
276 void ColorizeDepthCUDA
289 int64_t cols = dst.GetShape(1);
290 int64_t n = rows * cols;
292 #if defined(__CUDACC__) 293 core::kernel::CUDALauncher launcher;
298 float inv_interval = 255.0f / (max_value -
min_value);
301 int64_t workload_idx) {
302 int64_t y = workload_idx / cols;
303 int64_t x = workload_idx % cols;
306 static_cast<float>(*src_indexer.
GetDataPtr<scalar_t>(x, y));
307 float out = in / scale;
308 out = out <= min_value ?
min_value : out;
309 out = out >= max_value ?
max_value : out;
311 int idx =
static_cast<int>(inv_interval * (out -
min_value));
312 uint8_t* out_ptr = dst_indexer.
GetDataPtr<uint8_t>(x, y);
313 out_ptr[0] = turbo_srgb_bytes[idx][0];
314 out_ptr[1] = turbo_srgb_bytes[idx][1];
315 out_ptr[2] = turbo_srgb_bytes[idx][2];
Definition: GeometryIndexer.h:168
Definition: CPULauncher.h:42
void ColorizeDepthCPU(const core::Tensor &src, core::Tensor &dst, float scale, float min_value, float max_value)
Definition: ImageImpl.h:280
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
Dtype GetDtype() const
Definition: Tensor.h:1025
#define OPEN3D_DEVICE
Definition: CUDAUtils.h:57
OPEN3D_HOST_DEVICE T * GetDataPtr(int64_t x) const
Definition: GeometryIndexer.h:324
OPEN3D_HOST_DEVICE int64_t GetShape(int i) const
Definition: GeometryIndexer.h:319
void PyrDownDepthCPU(const core::Tensor &src, core::Tensor &dst, float diff_threshold, float invalid_fill)
Definition: ImageImpl.h:91
void CreateVertexMapCPU(const core::Tensor &src, core::Tensor &dst, const core::Tensor &intrinsics, float invalid_fill)
Definition: ImageImpl.h:164
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
static void LaunchGeneralKernel(int64_t n, func_t element_kernel)
General kernels with non-conventional indexers.
Definition: CPULauncher.h:176
SizeVector GetShape() const
Definition: Tensor.h:988
#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:212
static Tensor Eye(int64_t n, Dtype dtype, const Device &device)
Create an identity matrix of size n x n.
Definition: Tensor.cpp:252
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
static const Dtype Float64
Definition: Dtype.h:43
#define max(x, y)
Definition: SVD3x3CPU.h:38
std::shared_ptr< core::Tensor > image
Definition: FilamentRenderer.cpp:228