Sign in to follow this  
Zebadee2323

Live Webcam footage to Direct3D texture

Recommended Posts

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

Share this post


Link to post
Share on other sites
_Sauce_    116
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.

Share this post


Link to post
Share on other sites
Muhammad Haggag    1358
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.

Share this post


Link to post
Share on other sites
Zebadee2323    122
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.

Share this post


Link to post
Share on other sites
Muhammad Haggag    1358
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this