Hello!
I'm trying to display a webcam into a TaharezLook/StaticImage
What i'm doing is grabing the image as a byte array... i can grab it at init and display it... no problem!
But now i would like to grab it continuously and display it... how can i do that?
I know that the setTexture is not a good idea (and is protected) and i'm not sure that destroying my imageset and creating it again with the new texture from memory is going to be fast enough! (cuz it should be quite fast to look like it is live.. no lag)
any idea on how to update/change the texture of an imageset in a fast and practical way? Or maybe a total other way of doing it!?
Thank you very much for your help!
Update a texture live (webcam)...
Moderators: CEGUI MVP, CEGUI Team
-
- Just popping in
- Posts: 5
- Joined: Thu Apr 05, 2007 09:41
This Ogre Wiki article uses a dynamically created image, by rendering rotating 3D objects to an image. If you are using Ogre as your renderer then you have a lot of the code already done for you. Otherwise you'll have to adapt the code to your specific renderer. That article should provide a good starting point for your application.
-
- Just popping in
- Posts: 5
- Joined: Thu Apr 05, 2007 09:41
You are not using only Cegui; you also need a renderer. It could be DirectX, OpenGL, Ogre, Irrlicht, etc.
The link to the Ogre wiki rotates a 3D model in front of a camera and the contents of that camera are placed within a texture, which is used to dynamically update an image displayed within Cegui. It uses the Ogre renderer, with some code specific for that renderer. However you should be able to go through that code and adapt it to the renderer you are using (I'm guessing DirectX or OpenGL).
The link to the Ogre wiki rotates a 3D model in front of a camera and the contents of that camera are placed within a texture, which is used to dynamically update an image displayed within Cegui. It uses the Ogre renderer, with some code specific for that renderer. However you should be able to go through that code and adapt it to the renderer you are using (I'm guessing DirectX or OpenGL).
-
- Just popping in
- Posts: 5
- Joined: Thu Apr 05, 2007 09:41
-
- Just popping in
- Posts: 5
- Joined: Thu Apr 05, 2007 09:41
I went trought the code, and i didnt find anywhere a way to update a texture of an imageset!
From a 3D object, the object is define, but what i want is that (for exemple if it is really slow) every second, my webcam gets a new image as a byte array. I create a new texture from this array with LoadFromMemory()
(until here it works well)
then i want to apply this texture to the imageset i'm displaying!
I have a window (staticimage) displaying the imageset called "ImgSet" and the image "ImgCam". So ImgSet as to change it's texture right so the image changes!
It's the only way i found to do it!
If something else to do, please let me know! I'm very new in CEGUI!
From a 3D object, the object is define, but what i want is that (for exemple if it is really slow) every second, my webcam gets a new image as a byte array. I create a new texture from this array with LoadFromMemory()
(until here it works well)
then i want to apply this texture to the imageset i'm displaying!
I have a window (staticimage) displaying the imageset called "ImgSet" and the image "ImgCam". So ImgSet as to change it's texture right so the image changes!
It's the only way i found to do it!
If something else to do, please let me know! I'm very new in CEGUI!
This is part of the code from DialogBuild::DialogBuild()
After this point I believe you would simply update the texture you created via DirectX or OpenGL.
Code: Select all
// Create an Ogre texture via DirectX or OpenGL
texName = "RttTex_" + StringConverter::toString(buttonIndex);
rttTex[buttonIndex] = global->root->getRenderSystem()->createRenderTexture(texName, RTT_WINDOW_SIZE, RTT_WINDOW_SIZE, TEX_TYPE_2D, PF_R8G8B8);
Ogre::TexturePtr ogreTex = Ogre::TextureManager::getSingletonPtr()->getByName(texName);
// Create a Cegui Texture via the Ogre Cegui Renderer
OgreCEGUITexture* ceguiTex = (OgreCEGUITexture*)global->guiRenderer->createTexture();
ceguiTex->setOgreTexture(ogreTex);
// Create a Cegui imageset from an OgreCeguiRenderer texture
imageSetName = "ButtonTextureImageset_" + StringConverter::toString(buttonIndex);
Imageset* textureImageSet = CEGUI::ImagesetManager::getSingleton().createImageset(imageSetName, ceguiTex);
textureImageSet->defineImage("RttTex", Point(0.0f, 0.0f), Size(ceguiTex->getWidth(), ceguiTex->getHeight()), Point(0.0f,0.0f));
imageSetName = "set:ButtonTextureImageset_" + StringConverter::toString(buttonIndex) + " image:RttTex";
// Use that Cegui image for the various states of the button
rootWindow->getChild(buttonID[buttonIndex])->setProperty("NormalImage", imageSetName);
rootWindow->getChild(buttonID[buttonIndex])->setProperty("HoverImage", imageSetName);
rootWindow->getChild(buttonID[buttonIndex])->setProperty("PushedImage", imageSetName);
After this point I believe you would simply update the texture you created via DirectX or OpenGL.
From the Ogre message board: Webcam Plugin. The source code may inspire you, or you may decide that going the Ogre way is the simplest solution.
-
- Just popping in
- Posts: 5
- Joined: Thu Apr 05, 2007 09:41
I did it! now i can live change the texture.
The problem now is that i put i timer in my CEGUI application and a thread, the thread catches the images from the webcams (two webcams actually)
and in my CEGUI application timer, i'm changing the texture of my imageset using the byte array got in the thread.
Probleme is... if i put a 0.5 second delay for my timer, the CEGUI application is good (120fps) but of course, my webcam images are slow... so if i want a pseudo live webcam display, i'm putting the delay at 0.05 secondes ... there the webcam are quite fast.. great but my CEGUI app is now runing at 11 fps which is REAL bad!
Have any idea on where the problem comes from and if i can resolve it?
Thank you very much
The problem now is that i put i timer in my CEGUI application and a thread, the thread catches the images from the webcams (two webcams actually)
and in my CEGUI application timer, i'm changing the texture of my imageset using the byte array got in the thread.
Probleme is... if i put a 0.5 second delay for my timer, the CEGUI application is good (120fps) but of course, my webcam images are slow... so if i want a pseudo live webcam display, i'm putting the delay at 0.05 secondes ... there the webcam are quite fast.. great but my CEGUI app is now runing at 11 fps which is REAL bad!
Have any idea on where the problem comes from and if i can resolve it?
Thank you very much
Who is online
Users browsing this forum: No registered users and 28 guests