31 const float **pp_x_table,
const float **pp_y_table,
33 uint32_t n_sensor_rows, uint32_t n_sensor_cols, uint32_t n_out_rows,
34 uint32_t n_out_cols, uint32_t n_offset_rows, uint32_t n_offset_cols,
35 uint8_t row_bin_factor, uint8_t col_bin_factor, uint8_t iter) {
36 uint32_t n_cols = n_sensor_cols / col_bin_factor;
37 uint32_t n_rows = n_sensor_rows / row_bin_factor;
39 float *p_xp = (
float *)malloc(n_rows * n_cols *
sizeof(
float));
40 float *p_yp = (
float *)malloc(n_rows * n_cols *
sizeof(
float));
41 float *p_z = (
float *)malloc(n_rows * n_cols *
sizeof(
float));
43 if ((p_xp ==
NULL) || (p_yp ==
NULL) || ((p_z ==
NULL))) {
54 float cx = p_intr_data->
cx / row_bin_factor;
55 float cy = p_intr_data->
cy / col_bin_factor;
59 float r_min = sqrt((
float)(n_rows * n_rows + n_cols * n_cols));
64 for (uint32_t
i = 0;
i < n_cols;
i++) {
69 for (uint32_t j = 0; j < n_rows; j++) {
70 memcpy(&p_xp[j * n_cols], p_xp, n_cols *
sizeof(
float));
73 for (uint32_t j = 0; j < n_rows; j++) {
75 float value = (float)j;
76 for (uint32_t
i = 0;
i < n_cols;
i++) {
78 p_yp[j * n_cols +
i] =
value;
82 UndistortPoints(p_xp, p_yp, p_xp, p_yp, p_intr_data, iter, n_rows, n_cols,
83 row_bin_factor, col_bin_factor);
85 for (uint32_t j = 0; j < n_rows; j++) {
86 for (uint32_t
i = 0;
i < n_cols;
i++) {
87 int idx = j * n_cols +
i;
90 p_z[
idx] = sqrtf(xp * xp + yp * yp + 1);
94 float ix = (float)
i - cx;
95 float iy = (float)j - cy;
96 float r = sqrt(ix * ix + iy * iy);
108 for (uint32_t j = 0; j < n_rows; j++) {
109 for (uint32_t
i = 0;
i < n_cols;
i++) {
110 int idx = j * n_cols +
i;
111 float ix = (float)
i - cx;
112 float iy = (float)j - cy;
113 float r = sqrt(ix * ix + iy * iy);
126 float *p_xfull = p_xp;
127 float *p_yfull = p_yp;
128 float *p_zfull = p_z;
130 p_xp = (
float *)malloc(n_out_rows * n_out_cols *
sizeof(
float));
131 p_yp = (
float *)malloc(n_out_rows * n_out_cols *
sizeof(
float));
132 p_z = (
float *)malloc(n_out_rows * n_out_cols *
sizeof(
float));
134 for (uint32_t j = 0; j < n_out_rows; j++) {
135 for (uint32_t
i = 0;
i < n_out_cols;
i++) {
136 int idx = (j + n_offset_rows) * n_cols +
i + n_offset_cols;
137 int crop_idx = j * n_out_cols +
i;
138 float x = p_xfull[
idx];
139 float y = p_yfull[
idx];
140 float z = p_zfull[
idx];
142 p_xp[crop_idx] =
x /
z;
143 p_yp[crop_idx] =
y /
z;
144 p_z[crop_idx] = 1 /
z;
162 int16_t *p_xyz_image, uint32_t n_rows,
165 for (
int pixel_id = 0; pixel_id < n_rows * n_cols; pixel_id++) {
166 p_xyz_image[3 * pixel_id + 0] = (int16_t)(floorf(
167 p_xyz_data->
p_x_table[pixel_id] * (
float)p_depth[pixel_id] + 0.5f));
169 p_xyz_image[3 * pixel_id + 1] = (int16_t)(floorf(
170 p_xyz_data->
p_y_table[pixel_id] * (
float)p_depth[pixel_id] + 0.5f));
172 p_xyz_image[3 * pixel_id + 2] = (int16_t)((
173 p_xyz_data->
p_z_table[pixel_id] * (
float)p_depth[pixel_id] + 0.5f));