jojo wrote: > GL_LUMINANCE is for gray scale images. For example if you want to save the > depth buffer.
Ok, thus, I should use GL_RGBA. jojo wrote: > > Besides you should post a little bit more code. I don't know how much > experience your have with open scene graph. Maybe you didn't call the frame() > method of your viewer, the camera is not attached to a node or maybe there is > just nothing to see in the viewing frustum? > My camera is attached to the root of the scene graph. I retrieve the image during the rendering loop (it's true I didn't do it at first...), thus after 5 viewer.frame ('cause I setted it at 5). There is something to see from my camera. jojo wrote: > > Did you display the camera normaly which means with turned off offscreen > rendering? > However, I don't know what you mean here, it seems to be a key point... I've read things about pre-render, but you don't do any, right? Here's a bit of my code: I create the camera: Code: ref_ptr<Camera> MyPTMutils::createCamera(Matrix& cameraIntrinsic, Matrix& cameraPosition) { // parameters for MyPTM double width = cameraIntrinsic(0, 2)*2; double height = cameraIntrinsic(1, 2)*2; double fy = cameraIntrinsic(1, 1); // create camera for MyPTM ref_ptr<Camera> new_camera = new Camera(); new_camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); new_camera->setViewport(0, 0, width, height); new_camera->setProjectionMatrixAsPerspective((360./PI)*atan(height/(2*fy)) , (double)width/height, 1.0, 1000.0); new_camera->setViewMatrix(Matrix::inverse(cameraPosition)); return (new_camera); } I modify the camera (I know this can seem strange out of the context): Code: MyPTM::MyPTM(Geode* _arg_geode, std::string imgpath , int _arg_textureUnit, float focal, Quat &rotation, Vec3d position) { ref_ptr<osg::Image> img = osgDB::readImageFile(imgpath); cu = img->s(); cv = img->t(); Vec2f *vec = new Vec2f(cu,cv); MyPTMutils::setClosestPowerOfTwo(vec); ... _camera = MyPTMutils::createCamera(cameraIntrinsic, transform); _texture = new Texture2D(osgDB::readImageFile(imgpath)); _camera->setReferenceFrame(Transform::ABSOLUTE_RF); _camera->setDataVariance(Object::DYNAMIC); _depth = new Image(); _depth->allocateImage(vec->x(), vec->y(), 1, GL_RGBA, GL_UNSIGNED_BYTE); _camera->attach(osg::Camera::COLOR_BUFFER, _depth.get(),0,0); And the print: Code: float* bl = (float*)(_depth->data()); osgDB::writeImageFile(*_depth.get(),"depth.png"); This makes me think: why a float* ? And the main Code: MyPTM* myptm2 = new MyPTM((Geode*) (root->getChild(2)), "../Media/Data_Calibrage/Image/IMG_5316_small.jpg", 0, 720.0, r, camposition); myptm2->_camera->setView(&viewer); viewer.addSlave(myptm2->_camera.get()); viewer.setSceneData( root.get()); viewer.realize(); int once = 0; while( !viewer.done() ) { viewer.frame(); if (once == 50) myptm2->printDepthImage(); once++; } ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12271#12271 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org