Hi,

I am doing some exporments on Augmented Reality . In my programe i need to 
display 3D OSG model and videos for a selected markers. 
 
My marker traking lib is giving a 4X4 matrix. By setting this matrix to a 
transformation matrix I am able to display OSG model on the marker.

But for the video I need to display on full screen or the same size as of video 
. So I am not assigning any matrix to the transformation matrix. With this no 
video displayed on the screen. 
So I assigned a matrix statically to the transformation matrix then I am able 
to see video on the screen. The code is given bellow


Code:

double temp_mat_1[16]={-0.999,0.003,0.011,0,
                                                                                
      -0.010,-0.700,-0.713,0,
                                                                                
   0.005,-0.713,0.700,0,
                                                                                
   194.047,121.5,-276.475,1
};
mat.set(temp_mat_1);
videoTransMat->setMatrix(mat);
videoStrm ->seek(0);
videoStrm ->play();




Doing this way is making problem to me. Because I need to change the matrix 
every time when the video resolution changes. 

When I do a sample program to load video then it displayes with the same 
resolution as of the video. In this program the transformation matrix does not 
contain any thing. The code is given bellow


Code:
void main()
   {
   osg::ref_ptr<osg::ImageStream> mImageStream;
   //osg::ref_ptr<osg::Texture> mVideoTexture;
   osg::ref_ptr<osg::Texture2D> mVideoTexture;
   osg::ref_ptr<osg::Geode> mVideoGeode;
   osg::ref_ptr<osg::Geode> geode = new osg::Geode;
   osg::Image* img;

   img = osgDB::readImageFile("C:\\Test\\ar352wa.mp4.ffmpeg");
   mImageStream = dynamic_cast<osg::ImageStream*>(img);
   mVideoTexture = new osg::Texture2D;
   mVideoTexture->setImage( mImageStream.get() );


   geode->addDrawable(osg::createTexturedQuadGeometry(
         osg::Vec3(0, 0, 0),
         osg::Vec3(videoWidth, 0, 0),
         osg::Vec3(0, 0, videoHeight)
         ));
   geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, mVideoTexture, 
osg::StateAttribute::ON );
   osg::MatrixTransform *    transformation = new osg::MatrixTransform(); 
   transformation->addChild(geode.get());
   mImageStream->play();
   osgViewer::Viewer viewer;
   viewer.setCameraManipulator(new osgGA::TrackballManipulator());
   viewer.setUpViewInWindow (200, 200, 600, 600);
   viewer.setSceneData( transformation );
   while(!viewer.done())
   {

   viewer.frame();
   }
} 



Can you please help me what modification i need to do to my AR program to 
display the video.

AR Video Load code


Code:
img = osgDB::readImageFile(filename);
videoStrm = dynamic_cast<osg::ImageStream*>(img);
mVideoTexture = new osg::Texture2D;
geode = new osg::Geode;
mVideoTexture->setImage(videoStrm.get() );
       float videoWidth = img->s()*img->getPixelAspectRatio() ;
        float videoHeight =img->t();
geode->addDrawable(osg::createTexturedQuadGeometry(
                osg::Vec3(0, 0, 0),
                osg::Vec3(videoWidth, 0, 0),
                osg::Vec3(0, 0, videoHeight)
                ));
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, mVideoTexture, 
osg::StateAttribute::ON );
videoTransMat = new osg::MatrixTransform();
    videoTransMat->addChild(geode.get());
modelSwitch->addChild(videoTransMat);  



AR Viewer Settings


Code:
viewer = new osgViewer::Viewer();
viewer->setUpViewInWindow (200, 200, videoXRes, videoYRes);
viewer->getCamera()->setViewport(0,0,videoXRes,videoYRes);      
viewer->setLightingMode(osg::View::HEADLIGHT);
viewer->addEventHandler(new CSimpleWndSizeHandler(videoXRes,videoYRes));
/*p is projection matrix from camera*/
viewer->getCamera()->setProjectionMatrix(osg::Matrix(p)); 




Can you please help me what to do?
... 

Thank you!

Cheers,
Koduri

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47669#47669




_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to