I have got a directshow source filter which is based on http://tmhare.mvps.org/downloads/vcam.zip. I want to write the webcam frames that has been manipulated using opencv by my (separate) application, to this virtual webcam (Directshow filter). How can I do this?
Any helpful code snippets please?
A good practice for manipulating frames in Directshow is adding a SampleGrabber filter after your source filter. see
The SampleGrabber purpose is to manipulate frames.
Related
I need to use DirectShow (C++) for recording a webcam and saving the data to a file.
I really don't know how DirectShow works, this is a "stage" (working experience), but at school we didn't study it.
I think the best way to implement this could be:
List the video devices connected to the computer
Select the correct camera (there will be only one)
Retrieve the video
Save it to a file
Now there are two problems:
Where can I find a good reference book or how do I start?
The saved video shouldn't be too big, does DirectShow provide a way to compress it?
I won't use OpenCV because sometime it doesn't work properly (It doesn't find the camera).
Are there any high level wrapper that could help?
EDIT: the program won't have a window, it will run in background called by a dll.
Where can I find a good reference book or how do I start?
DirectShow introduction material
The saved video shouldn't be too big, does DirectShow provide a way to compress it?
Yes it provides capabilities to attach codecs, that needs to be installed in the system. These are typically third party codecs (for reasons beyond the scope of brief answer). You might want to record into Windows Media files to not depend on third party codecs. SWee more on MSDN: Choosing a Compression Filter.
This may be a dumb question but I'm having a hard time conceptualizing what I need to do here...In the past I've used DirectShow to connect to a camera and capture an AVI using a source filter, AVI mux, compression filter, run the graph, etc...piece of cake.
In this particular case I am getting notified when my non DirectShow camera driver has a buffer ready. I get notification and then I go and grab the BYTE* and render it using GDI. I now also need to create an AVI with these buffers.
Conceptually it makes sense for me to use something like vfw and write to an AVI stream every time I receive a buffer, of course vfw is old technology and I was also having some problems getting that to work (as I posted in a different forum).
How can I push these buffers into a DirectShow AVI Mux and write to a file? Do I have to create my own source filter to receive these buffers, then add my source filter and avi mux to a filter graph?
Thanks for any tips
So you have BYTE* with video frame data. It is very close to what you supposed. Your choices are to either use VFW AVIFileOpen and friends to write into AVI file, or inject data into DirectShow pipeline. To do the latter, you typically make your PushSource-like filter and push video frames from there (through AVI Mux to File Writer).
I have an application that relies on a C++ DirectShow transform filter, for the purpose of analyzing what is going on step by step I want to save each frame from the camera that the filter processes. What would be the simplest method to achieve this in the filter itself?
Can you insert sample grabber filter into the graph?
Beware though: the frame will be in some pixel format, and if it's not RGB24 you'll be in a lot of trouble to analyze it. If possible, configure your input source to RGB24 and you'll be on your way.
Expand your question if you need more info.
I have made two different solutions for Video-to-Image Capturing and was wondering if I could intertwine the best of both worlds. I am currently using DirectShow to load in an AVI file and capture images. However, DirectShow's lack of image processing capabilities and the need to make additional filters have stopped me dead in my tracks.
I then turned to OpenCV.
It has all the image processing functions I need, but it has trouble loading in the videos that the DirectShow solution was able to retrieve. Are there any tutorials online about this process or anything close to it? Thanks for any advice.
Yes, here is a link to an article: http://opencv.willowgarage.com/wiki/DirectShow
What's the most recommended way to go?
This is a pretty big topic. Try looking at OpenCV. It is nice for image and video manipulation, and you can stream video from files and webcams.
Take a look at DirectX "Filter Graphs". You can use a simple tool from the DirectX SDK called 'Graph Edit' to construct a sequence of DirectShow Filters which can do things like capture video streams from a TV card or decode an MPEG/AVI file and then operate on the data stream and ultimately render it to video/audio or a file.
Most of the DirectShow samples are in VC++.