10 namespace depth_to_rgb_calibration {
17 double x =
p[0] * point[0] +
p[1] * point[1] +
p[2] * point[2] +
p[3];
18 double y = p[4] * point[0] + p[5] * point[1] + p[6] * point[2] + p[7];
19 double z = p[8] * point[0] + p[9] * point[1] + p[10] * point[2] + p[11];
29 double x = (point[0] - intrin->
ppx) / intrin->
fx;
30 double y = (point[1] - intrin->
ppy) / intrin->
fy;
34 double r2 = x * x +
y *
y;
35 double r2c = 1 + intrin->
coeffs[0] * r2 + intrin->
coeffs[1] * r2*r2 + intrin->
coeffs[4] * r2*r2*r2;
40 double dx = xcd + 2 * intrin->
coeffs[2] * x*y + intrin->
coeffs[3] * (r2 + 2 * x*
x);
41 double dy = ycd + 2 * intrin->
coeffs[3] * x*y + intrin->
coeffs[2] * (r2 + 2 * y*
y);
47 pixel[0] = x * (double)intrin->
fx + (
double)intrin->
ppx;
48 pixel[1] =
y * (double)intrin->
fy + (
double)intrin->
ppy;
53 std::vector< double3 >
const &
points,
60 std::vector< double2 > uv_map( points.size() );
62 for(
auto i = 0;
i < points.size(); ++
i )
77 std::vector< double >
const & vals,
83 std::vector< double >
res( uv.size() );
85 for(
auto i = 0;
i < uv.size();
i++ )
97 res[
i] = std::numeric_limits<double>::max();
107 auto top_l = vals[int(
y1*width +
x1 )];
108 auto top_r = vals[int(
y1*width +
x2 )];
109 auto bot_l = vals[int(
y2*width +
x1 )];
110 auto bot_r = vals[int(
y2*width +
x2 )];
112 double interp_x_top, interp_x_bot;
115 interp_x_top = top_l;
116 interp_x_bot = bot_l;
120 interp_x_top = ((double)(
x2 -
x) / (double)(
x2 -
x1))*(
double)top_l + ((double)(
x -
x1) / (double)(
x2 -
x1))*(
double)top_r;
121 interp_x_bot = ((double)(
x2 -
x) / (double)(
x2 -
x1))*(
double)bot_l + ((double)(
x -
x1) / (double)(
x2 -
x1))*(
double)bot_r;
126 res[
i] = interp_x_bot;
130 auto interp_y_x = ((double)(
y2 -
y) / (double)(
y2 -
y1))*(
double)interp_x_top + ((double)(
y -
y1) / (double)(
y2 -
y1))*(
double)interp_x_bot;
136 f.open(
"interp_y_x" );
138 for(
auto i = 0;
i <
res.size();
i++ )
140 f <<
res[
i] << std::endl;
std::vector< double2 > uvmap_t
GLdouble GLdouble GLdouble y2
rs2_intrinsics_double get_intrinsics() const
static void distort_pixel(double pixel[2], const rs2_intrinsics_double *intrin, const double point[2])
static void transform_point_to_uv(double pixel[2], const p_matrix &pmat, const double point[3])
GLint GLsizei GLsizei height
std::vector< double > biliniar_interp(std::vector< double > const &vals, size_t width, size_t height, uvmap_t const &uv)
GLuint GLfloat GLfloat GLfloat x1
uvmap_t get_texture_map(std::vector< double3 > const &points, const calib &cal, const p_matrix &p_mat)