Live Webcam footage to Direct3D texture

Started by
3 comments, last by Muhammad Haggag 17 years, 4 months ago
Hey guys, I recently bought some servo motors and have built a sort of robot webcam. I can easily control these within my code. (I use c++ by the way) Today I had an idea of making a simple game which makes it look like the 3d objects are in the real world, by working out the correct view by using the servo motors angles. I want to have my live webcam feed in the background with my 3d renders on top. The way I saw it working in my head was to have the image somehow be converted to a Direct3D texture and have it displayed on a quad behind everything else. How would I: 1, Get an active image from the webcam 2, Render the image to a texture I want this to happen every frame, anyone have any ideas? Thanks.
Advertisement
You should check the website of your webcam manufacturer for a developers kit or something like that. I imagine that this would be the only way for you to intercept the data feed from your webcam.
You can capture video or images from a Webcam using DirectShow. Check the PlayCap sample, which comes with the Platform SDK samples.

Rendering video to texture can be done by using the VMR9 filter (Video Mixing Renderer). The VMR filter has 3 modes, one of which is the Renderless mode, which basically hands you a Direct3D9 surface IIRC.

Thanks for the replies, sorry for my late reply I have been away for a couple of days.

Anyway, gaining the live feed from the webcam hasn't been a problem with DirectShow, so thanks for that. However I can't find any information on how to use the VMR9 filter, the example included in the DirectShow SDK is absolutly awful I have spent hours trying to understand that thing with no luck.

If its not too much to ask, could you maybe make the shortest example of how I would use VMR9 in my project? All I want is a Direct3D texture containing the current frame from the cam and I should be able to take it from there.

Thanks.
Quote:Original post by Zebadee2323
Anyway, gaining the live feed from the webcam hasn't been a problem with DirectShow, so thanks for that. However I can't find any information on how to use the VMR9 filter, the example included in the DirectShow SDK is absolutly awful I have spent hours trying to understand that thing with no luck.

If its not too much to ask, could you maybe make the shortest example of how I would use VMR9 in my project? All I want is a Direct3D texture containing the current frame from the cam and I should be able to take it from there.

Well, the sample code tends to be very verbose and hard to follow. I'll try to write a simple example later today or tomorrow, as soon as I get some free time.

This topic is closed to new replies.

Advertisement