@@ -231,27 +231,25 @@ void DynaFuImpl<T>::drawScene(OutputArray depthImage, OutputArray shadedImage)
231
231
232
232
ogl::render (arr, idx, ogl::TRIANGLES);
233
233
234
- float f[ params.frameSize .width * params.frameSize .height ] ;
235
- float pixels[ params.frameSize .width * params.frameSize .height ][ 3 ] ;
236
- glReadPixels (0 , 0 , params.frameSize .width , params.frameSize .height , GL_DEPTH_COMPONENT, GL_FLOAT, &f[ 0 ] );
237
- glReadPixels (0 , 0 , params.frameSize .width , params.frameSize .height , GL_RGB, GL_FLOAT, &pixels[ 0 ][ 0 ] );
234
+ Mat depthData ( params.frameSize .height , params.frameSize .width , CV_32F) ;
235
+ Mat shadeData ( params.frameSize .height , params.frameSize .width , CV_32FC3) ;
236
+ glReadPixels (0 , 0 , params.frameSize .width , params.frameSize .height , GL_DEPTH_COMPONENT, GL_FLOAT, depthData. ptr () );
237
+ glReadPixels (0 , 0 , params.frameSize .width , params.frameSize .height , GL_RGB, GL_FLOAT, shadeData. ptr () );
238
238
239
239
// linearise depth
240
- for (int i = 0 ; i < params. frameSize . width *params. frameSize . height ; i++ )
240
+ for (auto it = depthData. begin < float >(); it != depthData. end < float >(); ++it )
241
241
{
242
- f[i] = farZ * nearZ / (f[i] *(nearZ - farZ) + farZ);
242
+ *it = farZ * nearZ / ((*it) *(nearZ - farZ) + farZ);
243
243
244
- if (f[i] >= farZ)
245
- f[i] = std::numeric_limits<float >::quiet_NaN ();
244
+ if (*it >= farZ)
245
+ *it = std::numeric_limits<float >::quiet_NaN ();
246
246
}
247
247
248
248
if (depthImage.needed ()) {
249
- Mat depthData (params.frameSize .height , params.frameSize .width , CV_32F, f);
250
249
depthData.copyTo (depthImage);
251
250
}
252
251
253
252
if (shadedImage.needed ()) {
254
- Mat shadeData (params.frameSize .height , params.frameSize .width , CV_32FC3, pixels);
255
253
shadeData.copyTo (shadedImage);
256
254
}
257
255
#else
0 commit comments