WIA Desktop Library

For the last couple weeks I’ve been struggling with getting camera capture inside a desktop application (yes – I lower myself to do desktop development occasionally).  The problem I’m finding is that API documentation and especially sample availability for things like DShow and Windows Image Acquisition (WIA) are pretty poor and there seem to be no reasonable, comprehensize samples on how to use any of it.  Occasionally you find something on sites like CodeProject, but IMO those projects tend to suck.  The authors typically “solve” a specific problem by writing code tightly coupled to the problem they’re solving, so the code is very rarely reusable or extensible, and the quality usually is lacking as well.

Well today I finished up a general library and test harness for WIA.  It’s too soon to tell if we’ll actually use it in the application I’m working on, since it’s missing a lot of capabilities that DShow will likely be better for, but to save a little headache in the developer community, I’m making it shared source (under our typical MIT x11 license).  It provides a simple object model for seeing what cameras you have, displaying live video from them and grabbing frames.  The test harness generates a TabControl with a page for each camera you have plugged in.  If you add or remove a camera while the app is running, tabs are added or removed.

Most importantly I designed the clas library for general use.  It can be dropped into any project and consumed for camera control without a bunch of rewrite, and while I’m not going to say it’s bug free, I at least tested it though several scenarios and let it run for a fairly long time without it puking (which is more than I can say about pretty much anything else I found).

Below is the object model and a screen shot of the test app.

Download the source code here (Updated 8/16/13).

3 thoughts on “WIA Desktop Library”

  1. Really Helpful project, but run into an PlatformNotSupportedException that states (WIA is not supported on platforms after Windows XP. Try using DShow or WPD instead.)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s