In some scenarios, such as Visitor Monitoring module for a government department or Patient Tracking module for a hospital, we may need to take a snap of human faces, patient charts, user IDs and so on and then upload them to a central server. How do we implement this for a web application?
How to interact with webcams connected to a computer in browsers?
- Flash – The web application requests permission to use the camera and the user will be presented with a dialog indicating the site wishes to use the camera. After the user accepts, the application will be able to grab images from the camera.
First, you’ll need to initialize and attach the camera
- HTML5 – The biggest hurdle is only a few browser versions support HTML 5. Details >>
- 3-rd party browser plugin – Internet Explorer can interact with an imaging peripheral through an ActiveX control. Firefox and Chrome can do the same through a plugin of Netscape Plugin Application Programming Interface (NPAPI).
In this article, we are going to take a look at the 3rd option – Dynamic Webcam SDK. Unlike in the first 2 options where a developer needs to deal with camera initialization, an image capturing, editing encoding and uploading separately, everything is encapsulated in Dynamic Webcam SDK.
Introduction to the Webcam API
Dynamic Webcam SDK is a browser plugin which enables users to acquire images from a webcam, edit and then upload/save them to a database, web server or local disk. Also, it can capture a live video stream into a container and grab a snapshot to be exported to a file/binary. The plugin works with all webcams that are compatible with Windows Image Acquisition (WIA) and USB video device class (UVC).
Two editions are provided for different browsers: ActiveX Edition for IE and Plugin Edition for other browsers on Windows OS.
|Client Side||Server Side|
|ActiveX Edition – x86 x64
Plugin Edition – on Windows
|IIS, Tomcat, Apache and more|
Here you can see a working application:
1. Initialize Dynamic Webcam SDK
Firstly, copy DynamicWebcam.cab to the web server. There are 32-bit and 64-bit CAB files. Choose the proper one according to the needs. The trial and full versions of Dynamic Webcam use different class-ids.
DynamicWebcam.cab can be found in the installation folder of Dynamic Webcam SDK.
For the TRIAL version of Dynamic Webcam, insert the following code in your JS code:
<object classid="clsid:A65BC1E1-B2CE-4251-A0CB-721AC7E02B52" id="DynamicWebcam1" width="143" height="156" CodeBase = "DynamicWebcam.cab#version=8,0"> </object>
Plug-in edition can be used in Gecko-based browsers including Firefox, Chrome, Safari & Opera on PC. Please copy DynamicWebcam.msi to the web server.