Hi,

i have a code for loading a video-texture as background for AR-purposes.

Basicly i grab the images from a webcam by DSVL and load them into an 
imagestream. The imagestream is connected to a Texture2D on a quadGeometry.
This code wroked fine for me but now i've used it in a similar application and 
I'm always getting a white/grey background (depending on lighting on/off).

When i store the images from the texture in a filesequence, everything is OK, 
so the stream is working. It must have st to to with the format , but i can't 
get it. when i load the images from disk they are applied to the quad...

Perhaps i've missed something in the new application, but as i can see it 
everything is the same,

so here is my code:


Code:

// initialization
_imageStream = new osg::ImageStream();  
_imageStream->allocateImage(_videoSource->getWidth(),_videoSource->getHeight(),1,GL_BGRA,GL_UNSIGNED_BYTE,1);
_imageStream->setDataVariance(osg::Object::DYNAMIC);

_texture = new osg::Texture2D(_imageStream.get());      
_texture->setDataVariance( osg::Object::DYNAMIC );
_texture->setResizeNonPowerOfTwoHint(false);
_texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
_texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);     
_texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
_texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);

_geometry = osg::createTexturedQuadGeometry(
osg::Vec3f(0,0,0),
osg::Vec3f(_videoSource->getWidth()/2,0,0),
osg::Vec3f(0,_videoSource->getHeight()/2,0),
0,
0,
1,
1);

_geode->addDrawable(_geometry); 
_geode->getOrCreateStateSet()->setTextureAttributeAndModes
                        (0,_texture, osg::StateAttribute::ON);

if (_imageStream) 
                        _imageStream->play();


// update-callback
_imageStream->setImage(_imageStream->s(),
_imageStream->t(),
1,
GL_TEXTURE_2D,
GL_BGRA,
GL_UNSIGNED_BYTE,
_videoSource->getImage()->getData(), 
osg::Image::NO_DELETE,
1);     






I'm desperate so  i hope someone can give me the right hint on this issue. I've 
tested with TextureRectangle but it wouldn't do it...

Thank you!

Cheers,
Patrick P.

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





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

Reply via email to