35 #include <Geometry/ProjectionParametersPerspective.hh>
36 #include <GLviewer/GLProjectionParametersPerspective.hh>
37 #include <GLviewer/Scenes/SceneOpenSceneGraph.hh>
38 #include <OpenGLFramework/RenderingContext/glfPBuffer.hh>
39 #include <Base/Image/ImageIO.hh>
44 int main(
int argc,
char *argv[]) {
79 ppp.
SetUndistortion(-0.1614995748,0.1328560412,-6.499856681e-005,0.0005424174597);
81 glppp.SwitchToOffscreenRendering(
true);
82 glppp.IgnoreDistortion(
false);
83 glppp.SetSimplePerspectiveCam(90);
86 vector<SceneBase*> scenes;
90 osg::Group* group =
new osg::Group;
91 osg::Geometry* geom =
new osg::Geometry;
92 osg::Vec3Array* vertices =
new osg::Vec3Array(4);
93 osg::StateSet *stateset = group->getOrCreateStateSet();
95 stateset->setMode(GL_CULL_FACE,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
100 geom->setVertexArray(vertices);
101 osg::Vec4Array* colors =
new osg::Vec4Array(1);
102 (*colors)[0].set(1.0f, 1.0f, 1.0f, 1.0f);
103 geom->setColorArray(colors);
104 geom->setColorBinding(osg::Geometry::BIND_OVERALL);
105 geom->addPrimitiveSet(
new osg::DrawArrays(GL_QUADS,0,4));
106 osg::Geode* geom_geode =
new osg::Geode;
107 geom_geode->addDrawable(geom);
108 group->addChild(geom_geode);
112 scenes.push_back(&sosg);
114 glppp.SetAutoReshapeBehaviour(GLProjectionParametersBase::AdaptToCroppedImage);
115 glppp.SetIntrinsics(&ppp);
116 glppp.SetGLMatrices();
117 glppp.SetZClippingPlanes(1.0,20.0);
118 int res=glppp.Draw(scenes);
119 res=glppp.Draw(scenes);
122 cerr<<
"draw returned "<<res<<endl;
127 glppp.GetImage(color);
128 cout <<
"get depth" << endl;
129 glppp.GetDepthMap(depth);
132 cerr<<
"draw image empty. "<<endl;
135 ImageIO::Save(
"distortest.mip",depth);
136 ImageIO::Save(
"distortest-c.mip",color);
141 if((d<9.8f)||(d>14.0f))
143 cerr <<
"unexpected depth value - distortion failed." <<endl;
virtual void SetR(const BIAS::RMatrix &R)
Set orientation from rotation matrix R.
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
void AppendSubTree(osg::ref_ptr< osg::Node > &childNode)
Append an OSG subtree to the constructed root tree.
void SetUndistortion(double kc1, double kc2)
Exception class used for run-time errors in the OpenGLFramework.
unsigned int GetWidth() const
virtual void Destroy()
Uninitializes the rendering context.
const std::string & GetMessageString() const
Returns the description of the error including the file name and line number where the error occured...
unsigned int GetHeight() const
GLX pbuffer rendering context.
Implements narrow access to OpenSceneGraph.
int Init()
Initializes OpenSG tree for scene appendance.
virtual void Init(const glfRenderingContextConfig &config)
Initializes the rendering context with the given configuration.
void SetSimplePerspective(const double FoV=M_PI/2, const unsigned int width=512, const unsigned int height=512)
Sets the parameters for a simple perspective camera with imagesize 512x512, focal length 512 (fov = 9...
Configuration for a rendering context.
virtual void SetC(const BIAS::Vector3< double > &C)
Set projection center.
class for rendering with projection parameters of ProjectionParametersPerspective ...
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase