@@ -73,7 +73,7 @@ DepthImageProjector::Impl::Impl(
7373 vbo_ (verticies_, GL_STATIC_DRAW),
7474 colorIn_(GL_SRGB8, colorWidth_, colorHeight_),
7575 depthIn_(GL_R16UI, depthWidth_, depthHeight_),
76- textureOut_(GL_SRGB8 , gridMapWidth, gridMapHeight), // TODO fix to RGB
76+ textureOut_(GL_RGB8 , gridMapWidth, gridMapHeight),
7777 colorSampler_(GL_LINEAR, GL_LINEAR, GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER),
7878 depthSampler_(GL_NEAREST, GL_NEAREST, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE),
7979 fbo_(textureOut_)
@@ -94,7 +94,7 @@ DepthImageProjector::Impl::Impl(
9494 vao_.mapVariable (vbo_, glGetAttribLocation (program_.get (), " position" ), 3 , GL_FLOAT, 0 );
9595
9696 // Enable blending
97- // glEnable(GL_BLEND);
97+ glEnable (GL_BLEND);
9898 glBlendFunc (GL_ONE, GL_ONE);
9999 glBlendEquation (GL_FUNC_ADD);
100100}
@@ -109,23 +109,6 @@ void DepthImageProjector::Impl::updateProjectionMatrix(
109109 glUniform2fv (glGetUniformLocation (program_.get (), " depthFocalLength" ) , 1 , depthFocalLength.data ());
110110 glUniform2fv (glGetUniformLocation (program_.get (), " depthCenter" ) , 1 , depthCenter.data ());
111111 glUniformMatrix4fv (glGetUniformLocation (program_.get (), " depthToColor" ), 1 , false , depthToColor.data ());
112-
113- // //TODO update projection matrix
114- // glUniform2f(glGetUniformLocation(program_.get(), "depthFocalLength"), 323.7779846191406, 323.7779846191406);
115- // glUniform2f(glGetUniformLocation(program_.get(), "depthCenter"), 322.2593078613281, 182.6495361328125);
116- // glUniform2f(glGetUniformLocation(program_.get(), "colorFocalLength"), 463.1402587890625, 463.0929870605469);
117- // glUniform2f(glGetUniformLocation(program_.get(), "colorCenter"), 320.7187194824219, 176.80926513671875);
118-
119- // //extrinsics matrix in column major order
120- // //TODO update the matrix using depth_to_color message
121- // //Note that the rotation variable in the message is column major order
122- // std::array<float, 16> depthToColorT = {
123- // 0.9999825954437256 , 0.0040609221905469894 , -0.004279938992112875 , 0,
124- // -0.00407175999134779, 0.9999884963035583 , -0.0025265226140618324, 0,
125- // 0.004269629716873169, 0.0025439055170863867 , 0.9999876618385315 , 0,
126- // 0.014667361974716187, 0.00030949467327445745, 0.0012093170080333948 , 1,
127- // };
128- // glUniformMatrix4fv(glGetUniformLocation(program_.get(), "depthToColor"), 1, false, depthToColorT.data());
129112}
130113
131114void DepthImageProjector::Impl::project (cv::Mat& dest, const cv::Mat& color, const cv::Mat& depth) // TODO add projection matrix argument
@@ -217,6 +200,42 @@ catch (cgs::gl::Exception& e)
217200
218201DepthImageProjector::~DepthImageProjector () = default ;
219202
203+ void DepthImageProjector::uniform (const std::string& name, float v1) {
204+ glUniform1f (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1);
205+ }
206+ void DepthImageProjector::uniform (const std::string& name, float v1, float v2) {
207+ glUniform2f (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1, v2);
208+ }
209+ void DepthImageProjector::uniform (const std::string& name, float v1, float v2, float v3) {
210+ glUniform3f (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1, v2, v3);
211+ }
212+ void DepthImageProjector::uniform (const std::string& name, float v1, float v2, float v3, float v4) {
213+ glUniform4f (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1, v2, v3, v4);
214+ }
215+ void DepthImageProjector::uniform (const std::string& name, int v1) {
216+ glUniform1i (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1);
217+ }
218+ void DepthImageProjector::uniform (const std::string& name, int v1, int v2) {
219+ glUniform2i (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1, v2);
220+ }
221+ void DepthImageProjector::uniform (const std::string& name, int v1, int v2, int v3) {
222+ glUniform3i (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1, v2, v3);
223+ }
224+ void DepthImageProjector::uniform (const std::string& name, int v1, int v2, int v3, int v4) {
225+ glUniform4i (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1, v2, v3, v4);
226+ }
227+ void DepthImageProjector::uniform (const std::string& name, unsigned int v1) {
228+ glUniform1ui (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1);
229+ }
230+ void DepthImageProjector::uniform (const std::string& name, unsigned int v1, unsigned int v2) {
231+ glUniform2ui (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1, v2);
232+ }
233+ void DepthImageProjector::uniform (const std::string& name, unsigned int v1, unsigned int v2, unsigned int v3) {
234+ glUniform3ui (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1, v2, v3);
235+ }
236+ void DepthImageProjector::uniform (const std::string& name, unsigned int v1, unsigned int v2, unsigned int v3, unsigned int v4) {
237+ glUniform4ui (glGetUniformLocation (impl_->program_ .get (), name.c_str ()), v1, v2, v3, v4);
238+ }
220239
221240void DepthImageProjector::updateProjectionMatrix (
222241 const std::array<float , 2 > colorFocalLength, const std::array<float , 2 > colorCenter,
0 commit comments