40 using t::geometry::kernel::TransformIndexer;
50 return abs_r < delta ? r : delta *
Sign(r);
55 return abs_r < delta ? 0.5 * r * r : delta * abs_r - 0.5 * delta * delta;
61 const float depth_outlier_trunc,
68 float* source_v = source_vertex_indexer.GetDataPtr<
float>(x, y);
69 if (isnan(source_v[0])) {
74 float T_source_to_target_v[3], u, v;
76 &T_source_to_target_v[0], &T_source_to_target_v[1],
77 &T_source_to_target_v[2]);
78 ti.
Project(T_source_to_target_v[0], T_source_to_target_v[1],
79 T_source_to_target_v[2], &u, &v);
83 if (T_source_to_target_v[2] < 0 ||
84 !target_vertex_indexer.InBoundary(u, v)) {
88 int ui =
static_cast<int>(u);
89 int vi =
static_cast<int>(v);
90 float* target_v = target_vertex_indexer.GetDataPtr<
float>(ui, vi);
91 float* target_n = target_normal_indexer.GetDataPtr<
float>(ui, vi);
92 if (isnan(target_v[0]) || isnan(target_n[0])) {
96 r = (T_source_to_target_v[0] - target_v[0]) * target_n[0] +
97 (T_source_to_target_v[1] - target_v[1]) * target_n[1] +
98 (T_source_to_target_v[2] - target_v[2]) * target_n[2];
99 if (abs(r) > depth_outlier_trunc) {
103 J_ij[0] = -T_source_to_target_v[2] * target_n[1] +
104 T_source_to_target_v[1] * target_n[2];
105 J_ij[1] = T_source_to_target_v[2] * target_n[0] -
106 T_source_to_target_v[0] * target_n[2];
107 J_ij[2] = -T_source_to_target_v[1] * target_n[0] +
108 T_source_to_target_v[0] * target_n[1];
109 J_ij[3] = target_n[0];
110 J_ij[4] = target_n[1];
111 J_ij[5] = target_n[2];
119 const float depth_outlier_trunc,
130 const float sobel_scale = 0.125;
132 float* source_v = source_vertex_indexer.GetDataPtr<
float>(x, y);
133 if (isnan(source_v[0])) {
138 float T_source_to_target_v[3], u_tf, v_tf;
140 &T_source_to_target_v[0], &T_source_to_target_v[1],
141 &T_source_to_target_v[2]);
142 ti.
Project(T_source_to_target_v[0], T_source_to_target_v[1],
143 T_source_to_target_v[2], &u_tf, &v_tf);
144 int u_t =
int(roundf(u_tf));
145 int v_t =
int(roundf(v_tf));
147 if (T_source_to_target_v[2] < 0 ||
148 !target_depth_indexer.InBoundary(u_t, v_t)) {
155 float depth_t = *target_depth_indexer.GetDataPtr<
float>(u_t, v_t);
156 float diff_D = depth_t - T_source_to_target_v[2];
157 if (isnan(depth_t) || abs(diff_D) > depth_outlier_trunc) {
161 float diff_I = *target_intensity_indexer.GetDataPtr<
float>(u_t, v_t) -
162 *source_intensity_indexer.GetDataPtr<
float>(x, y);
163 float dIdx = sobel_scale *
164 (*target_intensity_dx_indexer.GetDataPtr<
float>(u_t, v_t));
165 float dIdy = sobel_scale *
166 (*target_intensity_dy_indexer.GetDataPtr<
float>(u_t, v_t));
168 float invz = 1 / T_source_to_target_v[2];
169 float c0 = dIdx * fx * invz;
170 float c1 = dIdy * fy * invz;
171 float c2 = -(c0 * T_source_to_target_v[0] + c1 * T_source_to_target_v[1]) *
174 J_I[0] = (-T_source_to_target_v[2] * c1 + T_source_to_target_v[1] * c2);
175 J_I[1] = (T_source_to_target_v[2] * c0 - T_source_to_target_v[0] * c2);
176 J_I[2] = (-T_source_to_target_v[1] * c0 + T_source_to_target_v[0] * c1);
188 const float depth_outlier_trunc,
205 const float sqrt_lambda_intensity = 0.707;
206 const float sqrt_lambda_depth = 0.707;
207 const float sobel_scale = 0.125;
209 float* source_v = source_vertex_indexer.GetDataPtr<
float>(x, y);
210 if (isnan(source_v[0])) {
215 float T_source_to_target_v[3], u_tf, v_tf;
217 &T_source_to_target_v[0], &T_source_to_target_v[1],
218 &T_source_to_target_v[2]);
219 ti.
Project(T_source_to_target_v[0], T_source_to_target_v[1],
220 T_source_to_target_v[2], &u_tf, &v_tf);
221 int u_t =
int(roundf(u_tf));
222 int v_t =
int(roundf(v_tf));
224 if (T_source_to_target_v[2] < 0 ||
225 !target_depth_indexer.InBoundary(u_t, v_t)) {
232 float depth_t = *target_depth_indexer.GetDataPtr<
float>(u_t, v_t);
233 float diff_D = depth_t - T_source_to_target_v[2];
234 if (isnan(depth_t) || abs(diff_D) > depth_outlier_trunc) {
238 float dDdx = sobel_scale *
239 (*target_depth_dx_indexer.GetDataPtr<
float>(u_t, v_t));
240 float dDdy = sobel_scale *
241 (*target_depth_dy_indexer.GetDataPtr<
float>(u_t, v_t));
242 if (isnan(dDdx) || isnan(dDdy)) {
246 float diff_I = *target_intensity_indexer.GetDataPtr<
float>(u_t, v_t) -
247 *source_intensity_indexer.GetDataPtr<
float>(x, y);
248 float dIdx = sobel_scale *
249 (*target_intensity_dx_indexer.GetDataPtr<
float>(u_t, v_t));
250 float dIdy = sobel_scale *
251 (*target_intensity_dy_indexer.GetDataPtr<
float>(u_t, v_t));
253 float invz = 1 / T_source_to_target_v[2];
254 float c0 = dIdx * fx * invz;
255 float c1 = dIdy * fy * invz;
256 float c2 = -(c0 * T_source_to_target_v[0] + c1 * T_source_to_target_v[1]) *
258 float d0 = dDdx * fx * invz;
259 float d1 = dDdy * fy * invz;
260 float d2 = -(d0 * T_source_to_target_v[0] + d1 * T_source_to_target_v[1]) *
263 J_I[0] = sqrt_lambda_intensity *
264 (-T_source_to_target_v[2] * c1 + T_source_to_target_v[1] * c2);
265 J_I[1] = sqrt_lambda_intensity *
266 (T_source_to_target_v[2] * c0 - T_source_to_target_v[0] * c2);
267 J_I[2] = sqrt_lambda_intensity *
268 (-T_source_to_target_v[1] * c0 + T_source_to_target_v[0] * c1);
269 J_I[3] = sqrt_lambda_intensity * (c0);
270 J_I[4] = sqrt_lambda_intensity * (c1);
271 J_I[5] = sqrt_lambda_intensity * (c2);
272 r_I = sqrt_lambda_intensity * diff_I;
274 J_D[0] = sqrt_lambda_depth *
275 ((-T_source_to_target_v[2] * d1 + T_source_to_target_v[1] * d2) -
276 T_source_to_target_v[1]);
277 J_D[1] = sqrt_lambda_depth *
278 ((T_source_to_target_v[2] * d0 - T_source_to_target_v[0] * d2) +
279 T_source_to_target_v[0]);
280 J_D[2] = sqrt_lambda_depth *
281 ((-T_source_to_target_v[1] * d0 + T_source_to_target_v[0] * d1));
282 J_D[3] = sqrt_lambda_depth * (d0);
283 J_D[4] = sqrt_lambda_depth * (d1);
284 J_D[5] = sqrt_lambda_depth * (d2 - 1.0f);
286 r_D = sqrt_lambda_depth * diff_D;
TArrayIndexer< int64_t > NDArrayIndexer
Definition: GeometryIndexer.h:380
OPEN3D_HOST_DEVICE int Sign(int x)
Definition: GeometryMacros.h:96
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:116
#define OPEN3D_HOST_DEVICE
Definition: CUDAUtils.h:63
OPEN3D_HOST_DEVICE float HuberLoss(float r, float delta)
Definition: RGBDOdometryJacobianImpl.h:53
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:479
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:185
OPEN3D_HOST_DEVICE float HuberDeriv(float r, float delta)
Definition: RGBDOdometryJacobianImpl.h:48
Definition: PinholeCameraIntrinsic.cpp:35
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:58