Page 1 of 1

How to play video in viewport/screen

Posted: Sun Mar 22, 2015 8:52 pm
by camiloforero3
Hello everyone

I started using Ogre a couple of weeks ago, doing the tutorials and getting used to the structure. I want to use Ogre for an Augmented Reality like application, and for that one of the first things I need to do is to have a video playing on the screen background, and render whatever objects I might have on top of it. I've been searching in google and in these forums but I haven't found any clear answer to this, at most I can play the video over a texture but I don't know how to do that on the screen itself.

Eventually I will do this on a live video feed, but for demonstration purposes a prerecorded video should be enough.

Thank you for your help!

Re: How to play video in viewport/screen

Posted: Sun Mar 22, 2015 9:24 pm
by xrgo
Hello!! there is a plugin for that
Theora Plugin:
http://www.ogre3d.org/addonforums/viewf ... 1b2f217e1c

but I have no experience with it.

What I did one time is that I capture a webcam input, had to process it with openCV, then I fill a dynamic ogre texture, with a code like this one:
http://www.ogre3d.org/tikiwiki/tiki-ind ... c+textures

EDIT: I couldnt find my code but here is something related (opencv to ogreTexture)
http://www.ogre3d.org/forums/viewtopic. ... 13#p429477

Re: How to play video in viewport/screen

Posted: Mon Mar 23, 2015 7:09 am
by frostbyte
at most I can play the video over a texture but I don't know how to do that on the screen itself.
you can render the scene to a texture( rtt ) instead of a window, then you can blend the scene texture with the video texture as you wish using compositor or overlay material, you can also use skyBox/skydom material with the video texture but the perspective will be disorted
EDIT: I couldnt find my code but here is something related (opencv to ogreTexture)
viewtopic.php?f=5&t=64913#p429477
regarding the opencv code mentioned above...
no need to videoCapture->retrieve(frame, CV_CAP_OPENNI_BGR_IMAGE);
and then do copy frame->data to the texture pixelBox buffer

you can just do
mPixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD); // for best performance use HBL_DISCARD!
pDest = static_cast<Ogre::uchar*> (mPixelBox.data);
frame->data = pdest; //set opencv frame data pointer to the texture pixelBox HardwareBuffer
videoCapture->retrieve(frame, CV_CAP_OPENNI_BGR_IMAGE); //this will decode the captured frame directly to the texture hardware buffer( much faster )

its also better to use syedhs method of double buffer( texture ) with threading http://www.ogre3d.org/forums/viewtopic. ... 13#p429240
this way opencv decoding to texture will not damage the rendering loop performance

you also have scrawl's ffmpeg plugin http://www.ogre3d.org/forums/viewtopic.php?f=5&t=81934 which is very good
but for AR i would use openCV since it has the best multii-platform/vendor camera support and it can also use ffmpeg as a decoder backend...

Re: How to play video in viewport/screen

Posted: Wed Mar 25, 2015 12:43 am
by camiloforero3
Thank you! seems there is a lot of work ahead

The Theora plugin seems to be kind of dead at the moment, hasn't been touched since 2013 and the developer is not answering questions, I'm stuck at a compiling error and can't seem to go on. I will try the rtt route then, and see what happens