Retrieving snapshots from a webcam

by Geert 22. December 2008 09:23

One of my clients wanted a control that allows them to capture an image from either a hard-drive or a webcam using WPF. The first one isn't that hard, so I'll skip that one. The second is a bit thougher. When I searched the internet how to capture webcam images using WPF, I found this great blog entry by Tamir Khason.

One of the downsides of this control is that it displays the video rotated by 180 degrees using this Philips webcam. I also need a way to capture images when the user presses a button. I have made some small modifications to the CapPlayer class written by Tamir Khason. You can find the file attached to this blog, but below is a description of what I have added:

Added dependency property Rotation to CapPlayer
I have added a dependency property named Rotation. This code allows you to bind the rotation degree (in my case 180) for the video as well as the snapshots taken by using the CurrentBitmap property.

Added property CurrentBitmap to CapPlayer
I added a property named CurrentBitmap that retrieves the current bitmap in the video so it allows me to take snapshots.

Added Devices property to the CapDevice
Easily iterate through all the devices

Important update: this article has been updated into a new article.

WebcamPlayer.zip (13.89 kb) [Downloads: 3654]

kick it on DotNetKicks.com

A few enhancements to the CapPlayer class written by Tamir Khason

Tags:

C# | WPF

Pingbacks and trackbacks (1)+

Comments are closed

About the Author

Geert van Horrik is an independent freelance software developer since January 1st, 2007. Since then he was been working on several projects from C++ to C# (WPF, Silverlight, ASP.NET, etc). Currently he loves to write his software using WPF (or Silverlight if WPF isn't an option).

Lately, Geert is spending a lot of time on Catel, a free open-source MVVM Framework for WPF and Silverlight. Actually, it's more than "just" an MVVM Framework, it's a complete application library!