the sample of using Video As Texture

Started by
5 comments, last by pango99 20 years, 10 months ago
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.
fsdf
Advertisement
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.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/htm/usingdirectshowwhistler.asp




general idea:

- 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.


latency of the video stream?...other issues???

[edited by - _walrus on June 18, 2003 2:50:36 PM]
how bout this one (i''m on a mac right now so i can''t test it out) sounds like what u want to do though. U need to download directx SDK to try it out

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/htm/capturetexsample.asp
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.
fsdf
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!).
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:

http://mirror.ati.com/developer/gdc/GDC2003_VideoShader.pdf
1.there is no video compress in my filter graph;

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 renderer
when 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.

4.I don''t know which filter use the GDI,do you ?
fsdf

This topic is closed to new replies.

Advertisement