For all of these tests I used a Logitech c525 USB webcam. It is important to note that this webcam does not support taking single pictures or snapshots, and my goal was to try and simulate this feature as closely as possible.
This first test was actually a very simple project. I started with the source code I found here, which actually complied very nicely in Visual C# express 2010. I tidied up the interface a fair bit, and added a textbox that checks for an integer value when you press "Start". The textbox sets an interval in ms for how frequently a snapshot should be taken. I thought that doing this in WIA makes the most sense and was the easiest to implement. The biggest problem with this program (and this problem is carried over to the next 2 test programs as well) is that I wasn't able to figure out how to resize the captured video. Aside from that, the snapshot function worked very well!
Source/project files download (Visual C# Express 2010).
The next thing I wanted to do, mostly for fun, was record video using a webcam. The first thing I tried was DirectShow.Net. I downloaded the library files, but for whatever reason I still had problems recording video. I had to also add a reference for DirectShowLib-2005.dll, which is located with the source code files. The bulk of the code I used for the video capture aspect of this program came from the sample project located in Samples -> Capture -> CapWMV, which can be found through that link above.
Unfortunately I was very unhappy with the quality of video that was recorded, so I decided to look for another method.
Here's the source and project files (Visual C# Express 2010)
I ran into a lot of problems with this program, but thankfully the end result is a much higher quality video recording.
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/> <supportedRuntime version="v2.0.50727"></supportedRuntime> </startup>
Source code and project files (Visual C# Express 2010)
This was the biggest challenge so far. I was able to get a basic version of the snapshot working using Aforge.NET, but in a pretty ugly way. This program has 2 pictureboxes, one for the 'fluid' video, and one for the snapshot view. Both pictureboxes are always being manipulated by the program, but only one is visible at a time depending on what you're doing. When snapshot mode is engaged by clicking a button, 2 timers start running simultaneously, each taking a turn at flicking a boolean variable called snapshotTrigger on or off. When the 'fluid' video needs a new frame, the program checks to see what the variable is set to. When the program calls the FinalVideo_NewFrame function, there is a line that checks to see what this variable is set to. If it is true, then pictureBox2 gets an updated image. This variable is only true one moment for every interval, however, so most of the time the function finds that the value is false and does not update pictureBox2.Project files and whatnot (Visual C# Express 2010)
Just so I can end this series of tests with a usable program, I took the program from Test 4 above, removed all the snapshot code (because, really, who needs that?) and converted the program into a pure Webcam recorder. You connect to your Webcam, it automatically resizes the window based on the resolution you chose, and then you can record video! That's it! At least it's sort of useful, right??