Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PMDWarp.cpp
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #include "PMDWarp.hh"
26 #include <OpenGLFramework/Base/glfException.hh>
27 #include <Base/Debug/TimeMeasure.hh>
28 
29 using namespace BIAS;
30 using namespace std;
31 
32 bool timing=false;
33 TimeMeasure timer;
34 
35 void
37  bool targetParametersHaveDistortion)
38 {
39  pmdParams_ = pppd;
40  pmdParams_.GetImageSize(depthImageWidth_, depthImageHeight_);
41 
42  pmdDepthImage_.Create();
43  pmdDepthImage_.SetMinFilter(GL_NEAREST);
44  pmdDepthImage_.SetMagFilter(GL_NEAREST);
45  pmdDepthImage_.SetWrapS(GL_CLAMP);
46  pmdDepthImage_.SetWrapT(GL_CLAMP);
47  batch_.SetTexture(&pmdDepthImage_, 0);
48 
49  depthBufferMode_.SetDepthTest(true);
50  batch_.SetDepthBufferMode(&depthBufferMode_);
51 
52  batch_.SetProjectionMatrix(&Projection_);
53  batch_.SetModelViewMatrix(&modelView_);
54 
55  shaderProgram_.Create();
56  batch_.SetShaderProgram(&shaderProgram_);
57 
58  batch_.SetViewport(&viewport_);
59 
60  targetParametersHaveDistortion_ = targetParametersHaveDistortion;
61 
62  SetupShadersDefault_();
63 
64  SetupDefaultPrimitiveRendering_();
65 
66 }
67 
68 glfBatch&
70 {
71  return batch_;
72 }
73 
76 {
77  return depthBufferMode_;
78 }
79 
80 /** Upload the pmd depth image to the graphics card.
81  **/
82 void
84 {
85  pmdDepthImage_.UploadImage(pmdDepthImage);
86 }
87 
88 void
90 {
91  pmdDepthImage_.UploadImage(pmdDepthImage);
92 }
93 
94 void
96 {
97  projectiveTexture_.Create();
98  projectiveTexture_.SetMinFilter(GL_LINEAR);
99  projectiveTexture_.SetMagFilter(GL_LINEAR);
100  projectiveTexture_.SetWrapS(GL_CLAMP);
101  projectiveTexture_.SetWrapT(GL_CLAMP);
102  batch_.SetTexture(&projectiveTexture_, 1);
103 
105  relativePPP = ppp;
106  Pose relativePose;
107  relativePose.BecomeRelativeTransform(ppp.GetPose(), pmdParams_.GetPose());
108  relativePPP.SetPose(relativePose);
109  //cout<<"Projective Pose:"<<relativePose<<endl;
110 
111  //do not flip the texture because the image has been flipped
112  //implicitly by uploading it to graphics card
113  textureMatrix_.MakeTextureMatrixNew(relativePPP, false);
114  batch_.SetTextureMatrix(&textureMatrix_, 1);
115  //cout<<"K:\n"<<relativePPP.GetK()<<endl;
116  //cout<<"TextureMatrix:\n"<<textureMatrix_<<endl;
117  SetupShadersProjectiveTexturing_();
118 
119  shaderProgram_.SetUniform("C", relativePPP.GetC());
120 }
121 
122 void
124 {
125  projectiveTexture_.UploadImage(projectiveTexture);
126 }
127 
128 void
130 {
131  batch_.SetRenderTarget(renderTarget);
132 }
133 
134 void
135 PMDWarp::SetViewportSize(unsigned int width, unsigned int height)
136 {
137  viewport_.SetSize(width, height);
138  viewport_.SetOrigin(0, 0);
139 }
140 
141 //is also used to determine viewport
142 void
144  const ProjectionParametersPerspective& relativePpp,
145  double zNear,double zFar)
146 {
147  targetParams_ = relativePpp;
148  modelView_.MakeViewMatrixNew(targetParams_);
149  Projection_.MakeProjectionMatrixNew(targetParams_, zNear, zFar);
150 
151  if(targetParametersHaveDistortion_) {
152  double k0,k1,t0,t1;
153  targetParams_.GetUndistortion(k0, k1, t0,t1);
154  shaderProgram_.SetUniform("k0", k0);
155  shaderProgram_.SetUniform("k1", k1);
156  }
157 
158  unsigned int width, height;
159  targetParams_.GetImageSize(width, height);
160  viewport_.SetSize(width, height);
161  viewport_.SetOrigin(0, 0);
162 
163 }
164 
165 void
167  BIAS::Matrix4x4<double> projectionMatrix, unsigned int width,
168  unsigned int height)
169 {
170  modelView_.Make(modelViewMatrix);
171  Projection_.Make(projectionMatrix);
172  viewport_.SetSize(width, height);
173  viewport_.SetOrigin(0, 0);
174 }
175 
176 void
178 {
179  if (global)
180  {
181  batch_.SetProjectionMatrix(&globalModelViewNProjection_);
182  batch_.SetModelViewMatrix(&globalModelViewNProjection_);
183  }
184  else
185  {
186  batch_.SetProjectionMatrix(&Projection_);
187  batch_.SetModelViewMatrix(&modelView_);
188  batch_.SetDepthBufferMode(&depthBufferMode_);
189  }
190 }
191 
192 void
194 {
195  if (global)
196  {
197  batch_.SetViewport(&globalViewport_);
198  }
199  else
200  {
201  batch_.SetViewport(&viewport_);
202  }
203 }
204 
205 void
206 PMDWarp::ChangeZClipping(double zNear, double zFar)
207 {
208  Projection_.MakeProjectionMatrix(targetParams_, zNear, zFar);
209 }
210 
211 //renders the result into the forseen output
212 void
214 {
215 
216  if(timing){
217  timer.Start();
218  }
219  if (defaultRendering_)
220  {
221  unsigned int numIndicesPerStrip = depthImageWidth_ * 2;
222  unsigned int first = 0;
223  for (unsigned int y = 0; y < depthImageHeight_ - 1; y++)
224  {
225  batch_.SetRange(first, numIndicesPerStrip);
226  batch_.Draw();
227  first += numIndicesPerStrip;
228  }
229  }
230  else
231  {
232  BIASERR("no rendering implemented!\n");
233  }
234 
235  if(timing){
236  timer.Stop();
237  cout<<"PMDWarp::Draw:"; timer.PrintRealTime();
238  timer.Reset();
239  timer.Start();
240  }
241 }
242 
244  defaultRendering_(true)
245 {
246 }
247 
249 {
250 }
251 
252 void
254 {
255 
256  glfVertexFormat vertexFormat;
257  vertexFormat.AddAttribute(glfVertexFormat::ATTRIB_POSITION, GL_FLOAT, 4);
258  vertexFormat.AddAttribute(glfVertexFormat::ATTRIB_TEXCOORD, 0, GL_FLOAT, 2);
259  //vertexFormat.AddAttribute(VertexFormat::ATTRIB_COLOR, GL_FLOAT, 3);
260 
261  //const int numComponenents = 9;//4 for vertex 2 for tex coord 3 for color
262  const int numComponenents = 6;//4 for vertex 2 for tex coord
263  float* vertexData = new float[depthImageWidth_ * depthImageHeight_
264  * numComponenents];
265 
266  unsigned int count = 0;
267  for (unsigned int y = 0; y < depthImageHeight_; y++)
268  {
269  for (unsigned int x = 0; x < depthImageWidth_; x++)
270  {
271  HomgPoint2D imgPoint(x, y);
272  Vector3<double> ray, p;
273  pmdParams_.UnProjectLocal(imgPoint, p, ray);
274 
275  if(ray.NormL2() > 1e-12) ray.Normalize();
276  //else BIASERR("error");
277 
278  vertexData[count++] = static_cast<float> (ray[0]);
279  vertexData[count++] = static_cast<float> (ray[1]);
280  vertexData[count++] = static_cast<float> (ray[2]);
281  vertexData[count++] = 1.0;
282 
283  vertexData[count++] = (static_cast<float> (x) + 0.5)
284  / static_cast<float> (depthImageWidth_);
285  vertexData[count++] = (static_cast<float> (y) + 0.5)
286  / static_cast<float> (depthImageHeight_);
287 
288  // vertexData[count++] =
289  // (static_cast<float>(x)+0.5)/static_cast<float>(depthImageWidth_);
290  // vertexData[count++] =
291  // (static_cast<float>(y)+0.5)/
292  // static_cast<float>(depthImageHeight_);
293  // vertexData[count++] = 1.0;
294  }
295  }
296 
297  vertices_.Create(depthImageWidth_ * depthImageHeight_, vertexFormat,
298  vertexData);
300  delete[] vertexData;
301 
302  //************** INDICES ***********************
303  //creating coordinates for triangle strips!
304  //each image rows, except for the first and last, are contained twice
305  //a triangle strip consists of 2*width vertices
306  // and height-1 strips have to be rendered
307  GLuint* triangleIndices = new GLuint[depthImageWidth_ * (depthImageHeight_
308  - 1) * 2];
309  unsigned int numTriangleIndex = 0;
310  //
311  for (unsigned int y = 0; y < depthImageHeight_ - 1; y++)
312  {
313  for (unsigned int x = 0; x < depthImageWidth_; x++)
314  {
315  /* v1
316  * i0--- i2
317  * | / |
318  * | / |
319  * i1 i3
320  */
321  triangleIndices[numTriangleIndex++] = y * depthImageWidth_ + x;//up
322  triangleIndices[numTriangleIndex++] = (y + 1) * depthImageWidth_ + x;//below
323  }
324  }
325  elements_.Create(depthImageWidth_ * (depthImageHeight_ - 1) * 2,
326  GL_UNSIGNED_INT, GL_TRIANGLE_STRIP, triangleIndices);
328  delete[] triangleIndices;
329 
330  defaultRendering_ = true;
331 
332 }
333 
334 void
336 {
337 
338  stringstream vertexProgramCode;
339  vertexProgramCode<<
340  "uniform sampler2D pmdDepthImage;\n"
341  "uniform float scale = 1.0;"
342  "uniform float imageWidth = 900;"
343  "uniform float dist_from_cam = 2000;"
344  "uniform float disp_for_dist_from_cam = 255.0;"
345  "varying float disp;\n"
346  ""
347  "\n";
349  vertexProgramCode<<
350  "uniform float k0;\n"
351  "uniform float k1;\n"
352  "\n";
353  }
354 
355  vertexProgramCode<<
356  "void main() {\n"
357  " float depth = texture2D(pmdDepthImage, gl_MultiTexCoord0.st).r;\n"
358  " if(depth == 0) depth = 0.9;\n"
359  " vec4 depthAdjustedVertex = gl_Vertex * depth;\n"
360  " depthAdjustedVertex.w = 1.0; \n"
361  " depthAdjustedVertex = gl_ModelViewMatrix * depthAdjustedVertex;\n";
362 
363  //add distortion here:
365  vertexProgramCode<<
366  "float normalizedRad = (depthAdjustedVertex[0]*depthAdjustedVertex[0]);\n "
367  "normalizedRad += (depthAdjustedVertex[1]*depthAdjustedVertex[1]);\n"
368  "normalizedRad /= (depthAdjustedVertex[2]*depthAdjustedVertex[2]);\n"
369  "float scale = 1.0f + (k0 + k1*normalizedRad)*normalizedRad;\n"
370  "depthAdjustedVertex[0] = scale*depthAdjustedVertex[0];\n"
371  "depthAdjustedVertex[1] = scale*depthAdjustedVertex[1];\n";
372  }
373 
374  vertexProgramCode<<
375  "vec4 tmp = gl_ModelViewProjectionMatrix * vec4(imageWidth,0.0,0.0,0.0);"
376  "vec4 t = vec4(abs(((dist_from_cam*disp_for_dist_from_cam)/tmp[0])), 0.0,0.0,0.0);"
377  "vec4 proj_t = gl_ModelViewProjectionMatrix * t;"
378  ""
379  ""
380  "vec4 pos = gl_ProjectionMatrix * depthAdjustedVertex;\n"
381  "disp = scale*abs(proj_t[0]/pos[3])*imageWidth;"
382  ""
383  "gl_Position = pos;";
384  vertexProgramCode<<
385  " gl_TexCoord[0] = gl_MultiTexCoord0;\n"
386  "}";
387 
388  string fragmentProgramCode =
389  "varying float disp;"
390  ""
391  "void main() {"
392  "gl_FragData[0] = gl_TexCoord[0];"
393  "gl_FragData[1] = vec4(disp);"
394 
395  "}";
396 
397 
398  string geometryProgramCode = ""
399  "#extension GL_EXT_geometry_shader4 : enable\n"
400  ""
401  ""
402  "void main() {\n"
403  ""
404  ""
405  "vec4 v0 = gl_PositionIn[0];"
406  "vec4 v1 = gl_PositionIn[1];"
407  "vec4 v2 = gl_PositionIn[2];"
408  ""
409  "float dmax = max ( max ( distance(v0,v1), distance(v1,v2) ), distance(v0,v2) );"
410  ""
411  "if (dmax < 300) {"
412  ""
413  "gl_Position = v0;"
414  "gl_TexCoord[0] = gl_TexCoordIn[0][0];"
415  "EmitVertex();"
416  "gl_Position = v1;"
417  "gl_TexCoord[0] = gl_TexCoordIn[1][0];"
418  "EmitVertex();"
419  "gl_Position = v2;"
420  "gl_TexCoord[0] = gl_TexCoordIn[2][0];"
421  "EmitVertex();"
422  ""
423  "} else {"
424  ""
425  "}"
426  ""
427  ""
428  "}\n";
429 
430  vertexProgram_.Create(GL_VERTEX_SHADER, vertexProgramCode.str());
431  fragmentProgram_.Create(GL_FRAGMENT_SHADER, fragmentProgramCode);
432  geometryProgram_.Create(GL_GEOMETRY_SHADER_EXT, geometryProgramCode);
433 
437 
438  glProgramParameteriEXT(shaderProgram_.GetProgramId(),
439  GL_GEOMETRY_VERTICES_OUT_EXT, 3);
440  glProgramParameteriEXT(shaderProgram_.GetProgramId(),
441  GL_GEOMETRY_INPUT_TYPE_EXT, GL_TRIANGLES);
442  glProgramParameteriEXT(shaderProgram_.GetProgramId(),
443  GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_TRIANGLE_STRIP);
444 
446  shaderProgram_.SetUniform("pmdDepthImage", 0);
447 }
448 
449 void PMDWarp::SetDispForDistanceAndScale(const float& dist_from_cam,
450  const float& disp, const float& scale)
451 {
452  shaderProgram_.SetUniform("dist_from_cam", dist_from_cam);
453  shaderProgram_.SetUniform("disp_for_dist_from_cam", disp);
454  shaderProgram_.SetUniform("scale", scale);
455 }
456 
457 void
459  const BIAS::ProjectionParametersPerspective& relativePpp, double zNear,
460  double zFar, float N, int output)
461 {
462  //set the target rendering params
463  SetTargetCameraParameters(relativePpp, zNear, zFar);
464 
465  //calculate the constants needed
466  float FN = zNear * zFar;
467  float FMinusN = zFar - zNear;
468  float relativeHypoSpacing = FMinusN / N;
469 
470  stringstream fragmentProgramStream;
471  fragmentProgramStream << "uniform float zNear;" << "uniform float zFar;"
472  << "uniform float FMinusN;" << "uniform float FN;" << "uniform float N;"
473  << "uniform float D;";//relativeHypoSpacing
474 
475 
476  fragmentProgramStream << "void main() {"
477  << " float z = FN/(zFar - gl_FragCoord.z*FMinusN);"
478  << " float r = (z-zNear)/D;" << " float l = floor(r);" //lower representation
479  << " float u = ceil(r);" //upper representation
480  << " float w = r - l;" //relative distance
481  << " gl_FragData[" << output << "].r = l;" << " gl_FragData[" << output
482  << "].g = u;" << " gl_FragData[" << output << "].b = w;" << "}";
483 
484  try
485  {
486  fragmentProgram_.Create(GL_FRAGMENT_SHADER, fragmentProgramStream.str());
487  }
488  catch (glfException& e)
489  {
490 
491  std::cout << "Error: " << fragmentProgram_.GetInfoLog() << std::endl;
492  throw(e);
493  }
494 
495  //set appropriate constants
496  try
497  {
499  }
500  catch (glfException& e)
501  {
502  std::cout << "Error: " << shaderProgram_.GetInfoLog() << std::endl;
503  throw(e);
504  }
505  shaderProgram_.SetUniform("zNear", zNear);
506  shaderProgram_.SetUniform("zFar", zFar);
507  shaderProgram_.SetUniform("FN", FN);
508  shaderProgram_.SetUniform("FMinusN", FMinusN);
509  shaderProgram_.SetUniform("D", relativeHypoSpacing);
510  shaderProgram_.SetUniform("N", N);
511 }
512 
513 void
515 {
516  cout<<"projective texturing...\n";
517  stringstream vertexProgramCode;
518  vertexProgramCode<<
519  "uniform sampler2D pmdDepthImage;"
520  "uniform float scale = 1.0;"
521  "uniform float imageWidth = 900;"
522  "uniform float dist_from_cam = 2000;"
523  "uniform float disp_for_dist_from_cam = 255.0;"
524  "varying float disp;\n"
525  ""
526  "\n";
528  vertexProgramCode<<
529  "uniform float k0;\n"
530  "uniform float k1;\n"
531  "\n";
532  }
533  vertexProgramCode<<
534  "void main() {"
535  " float depth = texture2D(pmdDepthImage, gl_MultiTexCoord0.st).r;\n"
536  " if(depth == 0) depth = 0.9;\n"
537  " vec4 depthAdjustedVertex = gl_Vertex * depth;\n"
538  " depthAdjustedVertex.w = 1.0;\n"
539  " vec4 origdepthAdjustedVertex = depthAdjustedVertex;"
540  " depthAdjustedVertex = gl_ModelViewMatrix * depthAdjustedVertex;\n";
541 
542  //add distortion here:
544  vertexProgramCode<<
545  "float normalizedRad = (depthAdjustedVertex[0]*depthAdjustedVertex[0]);\n "
546  "normalizedRad += (depthAdjustedVertex[1]*depthAdjustedVertex[1]);\n"
547  "normalizedRad /= (depthAdjustedVertex[2]*depthAdjustedVertex[2]);\n"
548  "float scale = 1.0f + (k0 + k1*normalizedRad)*normalizedRad;\n"
549  "depthAdjustedVertex[0] = scale*depthAdjustedVertex[0];\n"
550  "depthAdjustedVertex[1] = scale*depthAdjustedVertex[1];\n";
551  }
552 
553  vertexProgramCode<<
554  "vec4 tmp = gl_ModelViewProjectionMatrix * vec4(imageWidth,0.0,0.0,0.0);"
555  "vec4 t = vec4(abs(((dist_from_cam*disp_for_dist_from_cam)/tmp[0])), 0.0,0.0,0.0);"
556  "vec4 proj_t = gl_ModelViewProjectionMatrix * t;"
557  ""
558  ""
559  "vec4 pos = gl_ProjectionMatrix * depthAdjustedVertex;\n"
560  "disp = scale*abs(proj_t[0]/pos[3])*imageWidth;"
561  ""
562  "gl_Position = pos;"
563  //use original depthadjusted vertex, without application of modelview matrix!!
564  "gl_TexCoord[0] = gl_TextureMatrix[1] * origdepthAdjustedVertex;"
565  "}";
566 
567  string fragmentProgramCode =
568  "uniform sampler2D projectiveTexture;"
569  ""
570  "varying float disp;"
571  ""
572  "void main() {"
573  "gl_FragData[0] = texture2DProj(projectiveTexture, gl_TexCoord[0]);"
574  "gl_FragData[1] = vec4(disp);"
575  "}";
576 
577  vertexProgram_.Create(GL_VERTEX_SHADER, vertexProgramCode.str());
578  fragmentProgram_.Create(GL_FRAGMENT_SHADER, fragmentProgramCode);
579 
580  //don't use already attached!
581  //shaderProgram_.AttachShader(vertexProgram_);
582  //shaderProgram_.AttachShader(fragmentProgram_);
584  shaderProgram_.SetUniform("pmdDepthImage", 0);
585  shaderProgram_.SetUniform("projectiveTexture", 1);
586 }
virtual BIAS::Vector3< double > GetC() const
Get projection center.
void ExecuteLinearHypothesesAssignment(const BIAS::ProjectionParametersPerspective &relativePpp, double zNear, double zFar, float N, int output=0)
Function is used to assign a hypotheses to the warped depth map.
Definition: PMDWarp.cpp:458
void BecomeRelativeTransform(const CoordinateTransform3D &newLocal, const CoordinateTransform3D &newGlobal)
Changes this coordinate transformation so that parameter newLocal becomes the local coordinate frame ...
void SetVertexBuffer(const glfVertexBuffer *vertexBuffer)
Sets the vertex buffer.
Definition: glfBatch.cpp:129
Defines the usage of the depth buffer.
BIAS::glfShader fragmentProgram_
Definition: PMDWarp.hh:172
void SetUniform(const std::string &varName, float value)
std::string GetInfoLog() const
Returns the info log containing information about the linking of the shader program.
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
void SetViewportSize(unsigned int width, unsigned int height)
Definition: PMDWarp.cpp:135
void SetRenderTarget(const BIAS::glfRenderTarget *renderTarget)
Definition: PMDWarp.cpp:129
void Link()
Links the attached shaders.
void AttachShader(const glfShader &shader)
Attaches a shader to the program.
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
bool targetParametersHaveDistortion_
Definition: PMDWarp.hh:188
void Create(GLenum type)
Creates the shader without the GLSL source code, use other Create() methods to upload source afterwar...
Definition: glfShader.cpp:55
void SetDispForDistanceAndScale(const float &dist_from_cam, const float &disp, const float &scale)
if disparity output is required, then points with the distance (dist_from_cam) will get disparity (di...
Definition: PMDWarp.cpp:449
BIAS::glfDepthBufferMode & GetDepthBufferMode()
Definition: PMDWarp.cpp:75
unsigned int depthImageHeight_
Definition: PMDWarp.hh:180
BIAS::glfVertexBuffer vertices_
Definition: PMDWarp.hh:164
BIAS::glfBatch & GetBatch()
Definition: PMDWarp.cpp:69
void SetupDefaultPrimitiveRendering_()
Definition: PMDWarp.cpp:253
void UploadProjectiveTexture(const BIAS::Image< unsigned char > &projectiveTexture)
Upload the color image to the graphics card.
Definition: PMDWarp.cpp:123
Exception class used for run-time errors in the OpenGLFramework.
Definition: glfException.hh:79
A batch represents a single Draw call including all parameters (render states).
Definition: glfBatch.hh:48
void GetUndistortion(double &kc1, double &kc2, double &kc3, double &kc4) const
void Create(int numVertices, const glfVertexFormat &format, const void *data=NULL, bool useBufferIfPossible=true)
Creates the vertex buffer for the given number of vertices and vertex format.
void Draw()
Definition: PMDWarp.cpp:213
virtual void SetPose(const BIAS::Pose pose)
Set pose from pose object.
void SetViewportToGlobal(bool global)
Definition: PMDWarp.cpp:193
BIAS::ProjectionParametersPerspective pmdParams_
Definition: PMDWarp.hh:153
Represents 3d pose transformations, parametrized as Euclidean translation and unit quaternion orienta...
Definition: Pose.hh:73
BIAS::glfShader geometryProgram_
Definition: PMDWarp.hh:173
void AddAttribute(Attribute attrib, int index, GLenum type, int size, bool normalized=false)
Adds a vertex attribute to the format.
void Init(const BIAS::ProjectionParametersPerspective &pppd, bool targetParametersHaveDistortion=false)
Initializes all neccessary data in order to render using a batch.
Definition: PMDWarp.cpp:36
void SetupShadersDefault_()
Definition: PMDWarp.cpp:335
bool defaultRendering_
Definition: PMDWarp.hh:182
virtual int GetImageSize(unsigned int &Width, unsigned int &Height) const
Obtain image dimensions.
void SetupShadersProjectiveTexturing_()
Definition: PMDWarp.cpp:514
void Create(int numIndices, GLenum type, GLenum mode, const void *indices)
Creates the element buffer for the given number of indices.
void PrintRealTime(std::ostream &os=std::cout, const bool &verbose=true) const
print the real time (=wall time clok)
A vertex format describes the attributes of a vertex.
void ChangeZClipping(double zNear, double zFar)
Definition: PMDWarp.cpp:206
void SetTargetCameraParametersToGlobal(bool global)
Definition: PMDWarp.cpp:177
void SetTargetCameraParameters(const BIAS::ProjectionParametersPerspective &relativePpp, double zNear, double zFar)
is also used to determine viewport
Definition: PMDWarp.cpp:143
void UseProjectiveTexturing(const BIAS::ProjectionParametersPerspective &ppp)
ppp extrinsicis have to be in global coordinates of pppd of Init call! projective texturing cannot d...
Definition: PMDWarp.cpp:95
void SetElementBuffer(const glfElementBuffer *elementBuffer)
Sets the element buffer.
Definition: glfBatch.cpp:134
virtual void UnProjectLocal(const HomgPoint2D &pos, Vector3< double > &pointOnRay, Vector3< double > &direction, bool IgnoreDistortion=false) const
calculates the viewing ray from the camera center (in the camera coordinate system) which belongs to ...
BIAS::glfShader vertexProgram_
Definition: PMDWarp.hh:171
Interface for render targets.
virtual const BIAS::Pose & GetPose() const
Return complete pose object.
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
BIAS::glfBatch batch_
Definition: PMDWarp.hh:178
unsigned int depthImageWidth_
Definition: PMDWarp.hh:179
void UploadDepthMap(const BIAS::Image< float > &pmdDepthImage)
Upload the pmd depth image to the graphics card.
Definition: PMDWarp.cpp:83
std::string GetInfoLog() const
Returns the info log containing information about the compilation of the shader.
Definition: glfShader.cpp:111
Vector3< T > & Normalize()
normalize this vector to length 1
Definition: Vector3.hh:663
class TimeMeasure contains functions for timing real time and cpu time.
Definition: TimeMeasure.hh:111
BIAS::glfElementBuffer elements_
Definition: PMDWarp.hh:165
double NormL2() const
the L2 norm sqrt(a^2 + b^2 + c^2)
Definition: Vector3.hh:633
BIAS::glfShaderProgram shaderProgram_
Definition: PMDWarp.hh:170