41 float near_clipping_plane_distance,
42 float far_clipping_plane_distance,
float fx,
float fy,
float cx,
43 float cy,
float base_line,
float disparity_resolution)
49 , base_line_(base_line)
50 , disparity_resolution_(disparity_resolution)
51 , padding_coefficients_(Eigen::Vector3f(disparity_resolution_ / (fx_ * base_line_), 0, 0))
60 fx_, fy_, cx_, cy_, base_line_, disparity_resolution_);
73 base_line_ = base_line;
78 disparity_resolution_ = disparity_resolution;
83 renderer.
setClippingRange(near_clipping_plane_distance_, far_clipping_plane_distance_);
96 return padding_coefficients_;
101 glUniform1f(glGetUniformLocation(renderer.
getProgramID(),
"near"), near_clipping_plane_distance_);
102 glUniform1f(glGetUniformLocation(renderer.
getProgramID(),
"far"), far_clipping_plane_distance_);
104 renderer.
setClippingRange(near_clipping_plane_distance_, far_clipping_plane_distance_);
115 "uniform vec3 padding_coefficients;"
118 " gl_FrontColor = gl_Color;"
119 " gl_BackColor = gl_Color;"
120 " vec4 vertex = gl_ModelViewMatrix * gl_Vertex;"
121 " vec3 normal = normalize(gl_NormalMatrix * gl_Normal);"
122 " float lambda = padding_coefficients.x * vertex.z * vertex.z + padding_coefficients.y * vertex.z + "
123 "padding_coefficients.z;"
124 " gl_Position = gl_ProjectionMatrix * (vertex + lambda * vec4(normal,0) );"
125 " gl_Position.y = -gl_Position.y;"
131 " gl_FragColor = gl_Color;"
138 " gl_FrontColor = gl_Color;"
139 " gl_TexCoord[0] = gl_MultiTexCoord0;"
140 " gl_Position = gl_Vertex;"
141 " gl_Position.w = 1.0;"
146 "uniform sampler2D sensor;"
147 "uniform sampler2D depth;"
148 "uniform sampler2D label;"
149 "uniform float near;"
151 "uniform float shadow_threshold;"
152 "const float shadowLabel = 1.0 / 255.0;"
153 "const float nearLabel = 2.0 / 255.0;"
154 "const float farLabel = 3.0 / 255.0;"
155 "float f_n = far - near;"
156 "float threshold = shadow_threshold / f_n;"
159 " float sValue = float(texture2D(sensor, gl_TexCoord[0].st));"
160 " if (sValue <= 0) {"
161 " gl_FragColor = vec4 (nearLabel, 0, 0, 0);"
165 " float dValue = float(texture2D(depth, gl_TexCoord[0].st));"
166 " float zValue = dValue * near / (far - dValue * f_n);"
167 " float diff = sValue - zValue;"
168 " if (diff < 0 && sValue < 1) {"
169 " gl_FragColor = vec4 (0, 0, 0, 0);"
170 " gl_FragDepth = float(texture2D(sensor, gl_TexCoord[0].st));"
171 " } else if (diff > threshold) {"
172 " gl_FragColor = vec4 (shadowLabel, 0, 0, 0);"
173 " gl_FragDepth = float(texture2D(sensor, gl_TexCoord[0].st));"
174 " } else if (sValue == 1) {"
175 " gl_FragColor = vec4 (farLabel, 0, 0, 0);"
176 " gl_FragDepth = float(texture2D(sensor, gl_TexCoord[0].st));"
178 " gl_FragColor = texture2D(label, gl_TexCoord[0].st);"
Abstracts the OpenGL frame buffer objects, and provides an interface to render meshes,...
void setBufferSize(unsigned width, unsigned height)
set the size of fram buffers
void setCameraParameters(float fx, float fy, float cx, float cy)
set the camera parameters
void setClippingRange(float near, float far)
sets the near and far clipping plane distances in meters
const GLuint & getProgramID() const
Abstract Interface defining Sensor Parameters.
Abstract Interface defining a sensor model for mesh filtering.
Parameters for Stereo-like devices.
void setBaseline(float base_line)
sets the base line = distance of the two projective devices (camera, projector-camera)
Parameters(unsigned width, unsigned height, float near_clipping_plane_distance, float far_clipping_plane_distance, float fx, float fy, float cx, float cy, float base_line, float disparity_resolution)
Constructor.
void setCameraParameters(float fx, float fy, float cx, float cy)
sets the camera parameters of the pinhole camera where the disparities were obtained....
~Parameters() override
Descturctor.
void setDisparityResolution(float disparity_resolution)
the quantization of disparity values in pixels. Usually 1/16th or 1/8th for OpenNI compatible devices
void setRenderParameters(GLRenderer &renderer) const override
set the shader parameters required for the model rendering
void setFilterParameters(GLRenderer &renderer) const override
set the shader parameters required for the mesh filtering
SensorModel::Parameters * clone() const override
polymorphic clone method
const Eigen::Vector3f & getPaddingCoefficients() const override
returns the coefficients that are required for obtaining the padding for meshes
static const std::string RENDER_VERTEX_SHADER_SOURCE
source code of the vertex shader used to render the meshes
static const std::string RENDER_FRAGMENT_SHADER_SOURCE
source code of the fragment shader used to render the meshes
static const StereoCameraModel::Parameters & REGISTERED_PSDK_PARAMS
predefined sensor model for OpenNI compatible devices (e.g., PrimeSense, Kinect, Asus Xtion)
static const std::string FILTER_FRAGMENT_SHADER_SOURCE
source code of the fragment shader used to filter the depth map
static const std::string FILTER_VERTEX_SHADER_SOURCE
source code of the vertex shader used to filter the depth map