Hi,

create the image once and update it's data every frame and call dirty on
the image. It looks ike Convert_OpenCV_TO_OSG_IMAGE returns a newly
created image everytime it gets called.

cheers,
Stephan


Am 10.07.12 10:25, schrieb Antonio De Giorgio:
> Hi,
> i have a problem with the streaming of the webcam as texture of a geode.. i 
> grap frames with opencv and than i create a osg::Image from every frame that 
> apply as a texture..Now how can i create a imagestream as it is done in the 
> osgMovie example? if i use the same dynamic_cast obviously it gives me back a 
> null object...than how can i make the texture update itself?
> 
> this is what i actually do (i'm now able to see just the first frame):
> 
> osg::Image* image = Convert_OpenCV_TO_OSG_IMAGE(imageCV);
>       //image->dirty();
> 
>       osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image);
>       
>             if (imagestream) 
>                               imagestream->play();
> 
>      if (image)
>             {
>                 osg::notify(osg::NOTICE)<<"image->s()"<<image->s()<<" 
> image-t()="<<image->t()<<std::endl;
>          
> geode->addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image,
>  useTextureRectangle, xyPlane, flip));
> 
>                 bottomright = pos + 
> osg::Vec3(static_cast<float>(image->s()),static_cast<float>(image->t()),0.0f);
> 
>                 if (xyPlane) pos.y() += image->t()*1.05f;
>                 else pos.z() += image->t()*1.05f;
>             }
> ... 
> 
> 
>    for(int i=0; (i<!viewer.done()); i++){
>        capture = cvCaptureFromCAM( 0 );
>               if ( !capture )
>            return -1;
>        imageCV = cvQueryFrame( capture );
>       
>       imageCV = cvQueryFrame( capture );
>       if( !imageCV ) return 1;
>       image = Convert_OpenCV_TO_OSG_IMAGE(imageCV);
>       image->dirty();
> 
>       // viewer.setSceneData(geode);
>                                                
> viewer.setThreadingModel(osgViewer::ViewerBase::SingleThreaded);   
>          
>          viewer.frame();
>                  }
> 
> 
> Thank you!
> 
> Cheers,
> Antonio
> 
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=48782#48782
> 
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 


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

Reply via email to