4 #ifndef LIBREALSENSE_RSUTIL2_H 5 #define LIBREALSENSE_RSUTIL2_H 15 static void rs2_project_point_to_pixel(
float pixel[2],
const struct rs2_intrinsics * intrin,
const float point[3])
19 float x = point[0] / point[2], y = point[1] / point[2];
25 float f = 1 + intrin->
coeffs[0]*r2 + intrin->
coeffs[1]*r2*r2 + intrin->
coeffs[4]*r2*r2*r2;
28 float dx = x + 2*intrin->
coeffs[2]*x*y + intrin->
coeffs[3]*(r2 + 2*x*x);
29 float dy = y + 2*intrin->
coeffs[3]*x*y + intrin->
coeffs[2]*(r2 + 2*y*y);
35 float r = sqrtf(x*x + y*y);
36 float rd = (float)(1.0f / intrin->
coeffs[0] * atan(2 * r* tan(intrin->
coeffs[0] / 2.0f)));
41 pixel[0] = x * intrin->
fx + intrin->
ppx;
42 pixel[1] = y * intrin->
fy + intrin->
ppy;
46 static void rs2_deproject_pixel_to_point(
float point[3],
const struct rs2_intrinsics * intrin,
const float pixel[2],
float depth)
52 float x = (pixel[0] - intrin->
ppx) / intrin->
fx;
53 float y = (pixel[1] - intrin->
ppy) / intrin->
fy;
57 float f = 1 + intrin->
coeffs[0]*r2 + intrin->
coeffs[1]*r2*r2 + intrin->
coeffs[4]*r2*r2*r2;
58 float ux = x*f + 2*intrin->
coeffs[2]*x*y + intrin->
coeffs[3]*(r2 + 2*x*x);
59 float uy = y*f + 2*intrin->
coeffs[3]*x*y + intrin->
coeffs[2]*(r2 + 2*y*y);
69 static void rs2_transform_point_to_point(
float to_point[3],
const struct rs2_extrinsics * extrin,
const float from_point[3])
77 static void rs2_fov(
const struct rs2_intrinsics * intrin,
float to_fov[2])
79 to_fov[0] = (atan2f(intrin->
ppx + 0.5f, intrin->
fx) + atan2f(intrin->
width - (intrin->
ppx + 0.5f), intrin->
fx)) * 57.2957795f;
80 to_fov[1] = (atan2f(intrin->
ppy + 0.5f, intrin->
fy) + atan2f(intrin->
height - (intrin->
ppy + 0.5f), intrin->
fy)) * 57.2957795f;
Definition: rs_types.h:47
float translation[3]
Definition: rs_sensor.h:85
float coeffs[5]
Definition: rs_types.h:65
float rotation[9]
Definition: rs_sensor.h:84
float ppx
Definition: rs_types.h:60
Exposes RealSense structs.
Definition: rs_types.h:49
int width
Definition: rs_types.h:58
Exposes RealSense sensor functionality for C compilers.
Definition: rs_types.h:48
Cross-stream extrinsics: encode the topology describing how the different devices are connected...
Definition: rs_sensor.h:82
rs2_distortion model
Definition: rs_types.h:64
float fy
Definition: rs_types.h:63
float fx
Definition: rs_types.h:62
Video stream intrinsics.
Definition: rs_types.h:56
int height
Definition: rs_types.h:59
float ppy
Definition: rs_types.h:61