Recommended Posts

Hi,
Is there any sample on the web or a bit of source code of
using video as texture? I want basically the ''Video (LIVE)
coming from a source (like USB Webcam/Other Capture
Device) to be loaded as a Texture. Will appreciate any
type of help in this regard.

0

Share this post

Link to post

Share on other sites

i'm sure it would be very similar to streaming a video (avi, mpeg, qt...etc) to a gl application. There's lots of demos around that do that so it shouldn't be much harder to extend the conecpt to work with a video device.

as for getting data from a video device. You can use directShow ( assuming ur using windows)

(look under "video capture", i'm sure that will get u started). Try google as well there should substantial info around the net.

- use TexImage2D to create a texture- get the next frame of the movie- use TexSubImage2D to copy the decoded movie frame to GPU- apply this texture to ur GL application (on a quad or whatever)

with video capture this should be very similar only movie data comes form video capture filter graph. Make sure the resolution of the video isn't that much or else it would be slow.

just brainstorming:what would be nice, would be some device that that you could plug the camera into that would downsample each incoming frame to a lower resolution and compress it using one of GL texture compression schemes, before it was sent to the GPU.

Share this post

Link to post

Share on other sites

I had written such a program using DirecShow(for video capturing)and "glTexImage2D", "glTexSubImage2D" functions,but I found the "glTexSubImage2D" can damage the performance of system,it will consume extra 150MHz of my 1.5G P4 CPU.I am not sure it is the problem of "glTexSubImage2D" or my computer(1.5G P4+768M SDRAM+Geforce Ti4200),but I found a similar sample in DirectX SDK and it will not consume any extra resource of CPU.I don''t how to use DirectX,so please give me some sample code or doc,so I can rewrite my program to improve performance.

0

Share this post

Link to post

Share on other sites

Guest Anonymous Poster

There are many things that could be hurting your performance in this case, and glTextureSubImage is probably not one of them. Did you have a video compressor in your filter graph? Were you using very large video frames to create your textures? What filter were you using to store the video image data? Some filters use the GDI (slow) and some use DirectDraw surfaces (fast!).

0

Share this post

Link to post

Share on other sites

The GDC 2003 presentation on realtime video processing might provide some useful references (there''s not much there interms of code, plus i think they use DirectX; there''s a couple of side that mention how they get the data across). It''s not much but it might help to further expand ur search:

Share this post

Link to post

Share on other sites

2.the texture size if 512*512,but I only create it for once,and then copy the "360*288" video frame into texture buffer using glTexSubImage();

3.I am using "SampleGrabber" filter to grabber video frame data,below is my graph:camera->splitter->decoder->"SampleGrabber" filter->null rendererwhen my program grabber a video frame,the callback function "SampleCB()" used by "SampleGrabber" send a message to main window and store the buffer pointer to "lParam" paramter,the main window then copy the video data into texture buffer and redraw the window.