[osg-users] Problem with Video Display

2012-05-14 Thread Koduri Lakshmi
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_ptrosg::ImageStream mImageStream;
   //osg::ref_ptrosg::Texture mVideoTexture;
   osg::ref_ptrosg::Texture2D mVideoTexture;
   osg::ref_ptrosg::Geode mVideoGeode;
   osg::ref_ptrosg::Geode geode = new osg::Geode;
   osg::Image* img;

   img = osgDB::readImageFile(C:\\Test\\ar352wa.mp4.ffmpeg);
   mImageStream = dynamic_castosg::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_castosg::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
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem with Video Display

2012-05-14 Thread Koduri Lakshmi
Hi,
Can any one help me how to slove this problem.

In my AR program if I set  viewersetCameraManipulator(new 
osgGA::TrackballManipulator()) then I am gettting the video output correctly. 
This time OSG model is not displayed on the marker(screen).

Here are my 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)); 



I think here TrackballManiplator is doing some default settings to the viewer. 
Can any one please help me what settings do i need to set to my AR program to 
get video display correctly.
... 

Thank you!

Cheers,
Koduri

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




___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org