21 using t::geometry::kernel::TransformIndexer;
31 return abs_r < delta ? r : delta *
Sign(r);
36 return abs_r < delta ? 0.5 * r * r : delta * abs_r - 0.5 * delta * delta;
42 const float square_dist_thr,
52 float* source_v = source_vertex_indexer.GetDataPtr<
float>(x, y);
53 if (isnan(source_v[0])) {
58 float T_source_to_target_v[3], u, v;
60 &T_source_to_target_v[0], &T_source_to_target_v[1],
61 &T_source_to_target_v[2]);
62 ti.
Project(T_source_to_target_v[0], T_source_to_target_v[1],
63 T_source_to_target_v[2], &u, &v);
67 if (T_source_to_target_v[2] < 0 ||
68 !target_vertex_indexer.InBoundary(u, v)) {
72 int ui =
static_cast<int>(u);
73 int vi =
static_cast<int>(v);
74 float* target_v = target_vertex_indexer.GetDataPtr<
float>(ui, vi);
75 if (isnan(target_v[0])) {
79 rx = (T_source_to_target_v[0] - target_v[0]);
80 ry = (T_source_to_target_v[1] - target_v[1]);
81 rz = (T_source_to_target_v[2] - target_v[2]);
82 float r2 = rx * rx + ry * ry + rz * rz;
83 if (r2 > square_dist_thr) {
88 J_x[0] = J_x[4] = J_x[5] = 0.0;
89 J_x[1] = T_source_to_target_v[2];
90 J_x[2] = -T_source_to_target_v[1];
93 J_y[1] = J_y[3] = J_y[5] = 0.0;
94 J_y[0] = -T_source_to_target_v[2];
95 J_y[2] = T_source_to_target_v[0];
98 J_z[2] = J_z[3] = J_z[4] = 0.0;
99 J_z[0] = T_source_to_target_v[1];
100 J_z[1] = -T_source_to_target_v[0];
109 const float depth_outlier_trunc,
116 float* source_v = source_vertex_indexer.GetDataPtr<
float>(x, y);
117 if (isnan(source_v[0])) {
122 float T_source_to_target_v[3], u, v;
124 &T_source_to_target_v[0], &T_source_to_target_v[1],
125 &T_source_to_target_v[2]);
126 ti.
Project(T_source_to_target_v[0], T_source_to_target_v[1],
127 T_source_to_target_v[2], &u, &v);
131 if (T_source_to_target_v[2] < 0 ||
132 !target_vertex_indexer.InBoundary(u, v)) {
136 int ui =
static_cast<int>(u);
137 int vi =
static_cast<int>(v);
138 float* target_v = target_vertex_indexer.GetDataPtr<
float>(ui, vi);
139 float* target_n = target_normal_indexer.GetDataPtr<
float>(ui, vi);
140 if (isnan(target_v[0]) || isnan(target_n[0])) {
144 r = (T_source_to_target_v[0] - target_v[0]) * target_n[0] +
145 (T_source_to_target_v[1] - target_v[1]) * target_n[1] +
146 (T_source_to_target_v[2] - target_v[2]) * target_n[2];
147 if (abs(r) > depth_outlier_trunc) {
151 J_ij[0] = -T_source_to_target_v[2] * target_n[1] +
152 T_source_to_target_v[1] * target_n[2];
153 J_ij[1] = T_source_to_target_v[2] * target_n[0] -
154 T_source_to_target_v[0] * target_n[2];
155 J_ij[2] = -T_source_to_target_v[1] * target_n[0] +
156 T_source_to_target_v[0] * target_n[1];
157 J_ij[3] = target_n[0];
158 J_ij[4] = target_n[1];
159 J_ij[5] = target_n[2];
167 const float depth_outlier_trunc,
178 const float sobel_scale = 0.125;
180 float* source_v = source_vertex_indexer.GetDataPtr<
float>(x, y);
181 if (isnan(source_v[0])) {
186 float T_source_to_target_v[3], u_tf, v_tf;
188 &T_source_to_target_v[0], &T_source_to_target_v[1],
189 &T_source_to_target_v[2]);
190 ti.
Project(T_source_to_target_v[0], T_source_to_target_v[1],
191 T_source_to_target_v[2], &u_tf, &v_tf);
192 int u_t =
int(roundf(u_tf));
193 int v_t =
int(roundf(v_tf));
195 if (T_source_to_target_v[2] < 0 ||
196 !target_depth_indexer.InBoundary(u_t, v_t)) {
203 float depth_t = *target_depth_indexer.GetDataPtr<
float>(u_t, v_t);
204 float diff_D = depth_t - T_source_to_target_v[2];
205 if (isnan(depth_t) || abs(diff_D) > depth_outlier_trunc) {
209 float diff_I = *target_intensity_indexer.GetDataPtr<
float>(u_t, v_t) -
210 *source_intensity_indexer.GetDataPtr<
float>(x, y);
211 float dIdx = sobel_scale *
212 (*target_intensity_dx_indexer.GetDataPtr<
float>(u_t, v_t));
213 float dIdy = sobel_scale *
214 (*target_intensity_dy_indexer.GetDataPtr<
float>(u_t, v_t));
216 float invz = 1 / T_source_to_target_v[2];
217 float c0 = dIdx * fx * invz;
218 float c1 = dIdy * fy * invz;
219 float c2 = -(c0 * T_source_to_target_v[0] + c1 * T_source_to_target_v[1]) *
222 J_I[0] = (-T_source_to_target_v[2] * c1 + T_source_to_target_v[1] * c2);
223 J_I[1] = (T_source_to_target_v[2] * c0 - T_source_to_target_v[0] * c2);
224 J_I[2] = (-T_source_to_target_v[1] * c0 + T_source_to_target_v[0] * c1);
236 const float depth_outlier_trunc,
253 const float sqrt_lambda_intensity = 0.707;
254 const float sqrt_lambda_depth = 0.707;
255 const float sobel_scale = 0.125;
257 float* source_v = source_vertex_indexer.GetDataPtr<
float>(x, y);
258 if (isnan(source_v[0])) {
263 float T_source_to_target_v[3], u_tf, v_tf;
265 &T_source_to_target_v[0], &T_source_to_target_v[1],
266 &T_source_to_target_v[2]);
267 ti.
Project(T_source_to_target_v[0], T_source_to_target_v[1],
268 T_source_to_target_v[2], &u_tf, &v_tf);
269 int u_t =
int(roundf(u_tf));
270 int v_t =
int(roundf(v_tf));
272 if (T_source_to_target_v[2] < 0 ||
273 !target_depth_indexer.InBoundary(u_t, v_t)) {
280 float depth_t = *target_depth_indexer.GetDataPtr<
float>(u_t, v_t);
281 float diff_D = depth_t - T_source_to_target_v[2];
282 if (isnan(depth_t) || abs(diff_D) > depth_outlier_trunc) {
286 float dDdx = sobel_scale *
287 (*target_depth_dx_indexer.GetDataPtr<
float>(u_t, v_t));
288 float dDdy = sobel_scale *
289 (*target_depth_dy_indexer.GetDataPtr<
float>(u_t, v_t));
290 if (isnan(dDdx) || isnan(dDdy)) {
294 float diff_I = *target_intensity_indexer.GetDataPtr<
float>(u_t, v_t) -
295 *source_intensity_indexer.GetDataPtr<
float>(x, y);
296 float dIdx = sobel_scale *
297 (*target_intensity_dx_indexer.GetDataPtr<
float>(u_t, v_t));
298 float dIdy = sobel_scale *
299 (*target_intensity_dy_indexer.GetDataPtr<
float>(u_t, v_t));
301 float invz = 1 / T_source_to_target_v[2];
302 float c0 = dIdx * fx * invz;
303 float c1 = dIdy * fy * invz;
304 float c2 = -(c0 * T_source_to_target_v[0] + c1 * T_source_to_target_v[1]) *
306 float d0 = dDdx * fx * invz;
307 float d1 = dDdy * fy * invz;
308 float d2 = -(d0 * T_source_to_target_v[0] + d1 * T_source_to_target_v[1]) *
311 J_I[0] = sqrt_lambda_intensity *
312 (-T_source_to_target_v[2] * c1 + T_source_to_target_v[1] * c2);
313 J_I[1] = sqrt_lambda_intensity *
314 (T_source_to_target_v[2] * c0 - T_source_to_target_v[0] * c2);
315 J_I[2] = sqrt_lambda_intensity *
316 (-T_source_to_target_v[1] * c0 + T_source_to_target_v[0] * c1);
317 J_I[3] = sqrt_lambda_intensity * (c0);
318 J_I[4] = sqrt_lambda_intensity * (c1);
319 J_I[5] = sqrt_lambda_intensity * (c2);
320 r_I = sqrt_lambda_intensity * diff_I;
322 J_D[0] = sqrt_lambda_depth *
323 ((-T_source_to_target_v[2] * d1 + T_source_to_target_v[1] * d2) -
324 T_source_to_target_v[1]);
325 J_D[1] = sqrt_lambda_depth *
326 ((T_source_to_target_v[2] * d0 - T_source_to_target_v[0] * d2) +
327 T_source_to_target_v[0]);
328 J_D[2] = sqrt_lambda_depth *
329 ((-T_source_to_target_v[1] * d0 + T_source_to_target_v[0] * d1));
330 J_D[3] = sqrt_lambda_depth * (d0);
331 J_D[4] = sqrt_lambda_depth * (d1);
332 J_D[5] = sqrt_lambda_depth * (d2 - 1.0f);
334 r_D = sqrt_lambda_depth * diff_D;
#define OPEN3D_HOST_DEVICE
Definition: CUDAUtils.h:44
OPEN3D_HOST_DEVICE int Sign(int x)
Definition: GeometryMacros.h:77
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 int
Definition: K4aPlugin.cpp:474
TArrayIndexer< int64_t > NDArrayIndexer
Definition: GeometryIndexer.h:360
OPEN3D_HOST_DEVICE bool GetJacobianHybrid(int x, int y, const float depth_outlier_trunc, const NDArrayIndexer &source_depth_indexer, const NDArrayIndexer &target_depth_indexer, const NDArrayIndexer &source_intensity_indexer, const NDArrayIndexer &target_intensity_indexer, const NDArrayIndexer &target_depth_dx_indexer, const NDArrayIndexer &target_depth_dy_indexer, const NDArrayIndexer &target_intensity_dx_indexer, const NDArrayIndexer &target_intensity_dy_indexer, const NDArrayIndexer &source_vertex_indexer, const TransformIndexer &ti, float *J_I, float *J_D, float &r_I, float &r_D)
Definition: RGBDOdometryJacobianImpl.h:233
OPEN3D_HOST_DEVICE float HuberDeriv(float r, float delta)
Definition: RGBDOdometryJacobianImpl.h:29
OPEN3D_HOST_DEVICE bool GetJacobianPointToPlane(int x, int y, const float depth_outlier_trunc, const NDArrayIndexer &source_vertex_indexer, const NDArrayIndexer &target_vertex_indexer, const NDArrayIndexer &target_normal_indexer, const TransformIndexer &ti, float *J_ij, float &r)
Definition: RGBDOdometryJacobianImpl.h:106
OPEN3D_HOST_DEVICE bool GetJacobianPointToPoint(int x, int y, const float square_dist_thr, const NDArrayIndexer &source_vertex_indexer, const NDArrayIndexer &target_vertex_indexer, const TransformIndexer &ti, float *J_x, float *J_y, float *J_z, float &rx, float &ry, float &rz)
Definition: RGBDOdometryJacobianImpl.h:39
OPEN3D_HOST_DEVICE bool GetJacobianIntensity(int x, int y, const float depth_outlier_trunc, const NDArrayIndexer &source_depth_indexer, const NDArrayIndexer &target_depth_indexer, const NDArrayIndexer &source_intensity_indexer, const NDArrayIndexer &target_intensity_indexer, const NDArrayIndexer &target_intensity_dx_indexer, const NDArrayIndexer &target_intensity_dy_indexer, const NDArrayIndexer &source_vertex_indexer, const TransformIndexer &ti, float *J_I, float &r_I)
Definition: RGBDOdometryJacobianImpl.h:164
OPEN3D_HOST_DEVICE float HuberLoss(float r, float delta)
Definition: RGBDOdometryJacobianImpl.h:34
Definition: PinholeCameraIntrinsic.cpp:16