Friday, April 19, 2024

Virtual Paper Keyboard Using OpenCV in Visual Studio

The project presented here uses a paper keyboard instead of an electronic keyboard as the input device. The paper keyboard, along with a webcam, forms a virtual keyboard. The virtual keyboard makes use of OpenCV software for video processing. The keyboard’s key characters are drawn on a white paper and a webcam is focused on it. You need to open a text editor such as Notepad. When you place your finger on a character on the paper keyboard, the character gets written in the text editor. The paper keyboard drawn on an A4-size white paper is shown in Fig. 1.

A2E_Fig_1
Fig. 1: Paper keyboard
AA8_Fig_2
Fig. 2: Typing the text on a virtual paper
5E6_Fig_3
Fig. 3: Setting the system variables

The advantages of this type of keyboard are its simplicity and wireless interface. Also, it is easy to use, because the user doesn’t have to press the keyboard but only touch the keys on the paper. The program output of virtual paper image (390×220 pixels) captured by the webcam is shown in Fig. 2.

449_Fig_4
Fig. 4: Screenshot of calibration window

Software program
The software is written in Visual C++. You need OpenCV software along with Visual Studio 2010 installed in your system.

OpenCV or Open Computer Vision, developed by Intel, is a set of tools used in image and video processing. To use this tool-set, you have to link the libraries with Visual Studio. OpenCV makes use of some simple functions to do the required processing.

Steps to install OpenCV2.3 for Visual Studio 2010 are (For EFY Plus DVD users):
1. Download OpenCV software from the following Web link: click here
2. Copy ‘OpenCV2.3’ folder to your ‘C:/’ drive.
3. Open Control Panel→System and Security→System→Advanced System Settings.
4. Click ‘Environmental Variables.’
5. Add ‘C:\OpenCV2.3\build\x86\vc9\bin’ to the environment path as shown in Fig. 3.
6. Run the setup file included in this month’s EFY DVD.
7. Run the virtual.sln file in Visual Studio 2010 (also included in DVD).
8. Compile it by clicking “Build Solution” option from ‘Build’ menu in Visual Studio 2010.
9. Now search for ‘Debug’ folder under ‘Virtual’ folder in ‘C’ drive.
10. Run the virtual.exe file.
11. Put the paper keyboard on the table. Focus the webcam on the keyboard.

- Advertisement -

Running the program for the first time
Running the program is not easy unless you calibrate the keyboard as explained below.

To use the virtual keyboard, calibration is to be done as per the image size (390×220 pixels) used in this project. That is, when you focus the webcam on the paper, the paper keyboard should be displayed properly on the program output screen. The program can be changed to work with other sizes also.

5D9_Code

- Advertisement -

When the virtual.exe program is executed, the video image captured by the webcam opens on your monitor screen. This window is used for calibration and also identifies the user’s finger. Adjust the camera position such that the keyboard lies in between the calibration red lines of the screen as shown in Fig. 4.

1 COMMENT

  1. Is there any way I could fix this issue “First-chance exception at 0x00007FF973337788 in VirtualKeyboard.exe: Microsoft C++ exception: cv::Exception at memory location 0x0000002494EFF6B0.” over my vstudio

Unique DIY Projects

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components

Calculators