Wednesday 25 December 2013

TWAIN vs WIA

Question:

I have taken up an academic project to work with the imaging devices, like video and still image capture. I have read about TWAIN and WIA as the popular toolkits or APIs available for the purpose. I need help in deciding as to which API is good to go with and guidance on any other tools or SDKs would also be of help.

By: Matt Charles

Answer:

You are right that TWAIN and WIA are the widely used APIs for applications around image acquisition. The choice of the toolkit can be made by looking at the following criteria:


  • OS Support: Microsoft's Windows Image Acquisition apparently works only on Windows platform. But TWAIN works on Windows, Linux and Mac. If your project requires cross platform solutions, then look at TWAIN or else WIA is preferred for its other advantages. While TWAIN is an offering of TWAIN Working Group having leading device vendors as its members, WIA is Microsoft's offering which builds on top of low-level hardware abstraction STI and is available with Windows Me or later.
  • Programming Support: Working with TWAIN API require C/C++ skills. There are commercial high level libraries which expose various programming language specific APIs for ease of use. WIA, though primarily designed for C/C++ development, it offers ease of use with .NET programming languages as well.
  • Device Support: Most of the windows compatible imaging devices including digital cameras, webcams, video cameras and scanners are WIA compatible. But not all devices come with TWAIN support. The list of devices supported by the TWAIN specification 2.3.0 can be found here


TWAIN though originally developed in 1992, it is a sophisticated API and its portability across various platforms. TWAIN also offers a 'native' (Device Independent Bitmap) transfer mode in addition to the modes 'memory' and 'file' offered by WIA. WIA provides a TWAIN compatibility layer that allows TWAIN-aware applications to communicate with WIA devices, though such applications will not have full access to WIA functionality.

Here are some cool references or code samples for image acquisition using WIA

ADF Scanner Library
OpenNETCF WIA Library

Some of the commercial APIs that make building TWAIN aware applications a lot easier are:

EZTwain Pro 4.0
csXImage - ActiveX Image edit and Twain control

You may also want to explore JS-Feat a javascript library.

Assuming that your project is of academic nature and that you would be looking at a windows specific solution, I would recommend you to explore WIA.