MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / depth2xyz

Function depth2xyz

tools/png2pcd.cpp:103–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103inline void
104depth2xyz (float v_viewing_angle, float h_viewing_angle,
105 int image_width, int image_height, int image_x, int image_y,
106 float depth, float &x, float &y, float &z)
107{
108 constexpr float PI = 3.1415927;
109
110 if (depth <= 0.0f)
111 {
112 x = y = z = std::numeric_limits<float>::quiet_NaN ();
113 }
114 else
115 {
116 float width = depth * std::tan (h_viewing_angle * PI / 180 / 2) * 2;
117 float height = depth * std::tan (v_viewing_angle * PI / 180 / 2) * 2;
118
119 x = (image_x - image_width / 2.0) / image_width * width;
120 y = (image_height / 2.0 - image_y) / image_height * height;
121 z = depth;
122 }
123}
124
125/* ---[ */
126int

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected