Introduction: How to Make Laser Projection Virtual Keyboard

The laser projection virtual keyboard designed in this thesis is based on OpenCV combine with image camera, 980nm linear laser, 980nm infrared filter and Keyboard projection laser, the image camera detection used with 980nm infrared filter is caused by shielding finger to make 980nm linear laser diffuse reflection the light . By detecting and locating the center position of the light outline to discern and detect the position of finger and then map to keyboard position to achieve relative keyboard key events. With OpenCV vision library, it is fast to find the finger outline which is get by image camera, the position of finger location and revise the image surface distortion which is caused by image camera. By using OpenCV, the bottom hardware drive code written can be reduced, and invoke built-in function can directly face to hardware write code to fasten the difficult and speed of program development. By experiment and test, this virtual keyboard can correctly and accurately locate and detect the finger position, on the other hand, this keyboard also have fault-tolerant treatment, and finally realize the function of key input.

You need:

Image camera: $ 20 (USD)

Keyboard projection laser: $ 38(USD)

Infrared filter: $ 6.1 (USD)

linear laser: $ 54 (USD)

Step 1: How to Work

在最下面的红外一字激光发射出红外线覆盖空间中的一个面,当然这个平面要覆盖整个键盘的范围,在中间的键盘投影键盘发出的是键盘形状的轮廓图形主要用于位置的标定,在最上面的摄像头实时拍摄外界图形并且把数据传递给电脑,因为一字激光发出的光线是和水平面平行的所以没有物体遮挡时摄像头是不能检测到红外线信号的,但是如果有物体在红外一字激光区域中时遮挡物体表面就会覆盖有红外线摄像头就会检测到红外线信号,电脑获取到摄像头发送过来的信号后经过一定的算法之后得到红外线亮点在图片中的坐标然后把这个坐标映射到现实中键盘的位置从而实现其功能。

Step 2: Select Camera Lens

检测相同面积镜头视角越广所安放的高度越低如图中所示Camera 2的视角是150°为了能检测所有的键盘投影范围所需要安装的高度需是h2而Camera 1的视角是90°同样为了检测所有的键盘投影范围所需要安装的高度需是h1由于Camera1的视角小于Camera 2所有必需得提高安装高度才能检测到同样的面积范围,为了缩小整个硬件系统故选择了视角为150°镜头的摄像头。

Step 3: 5V to 3.3V

由于红外激光需要5V供电而键盘投影激光是要3.3V供电使用需要一个3.3V的电源转换芯片使用使用了LT1117做为电源转换芯片,通过此转换电路后即可以给红外激光提供所需的5V电源也可以给键盘投影激光提供所需的3.3V电源。

Step 4: Software

软件部分的开发使用微软公司推出的集成开发环境Visual Studio 2010和OpenCV

Step 5: Camera Calibration

为了把装置做的小一点所以采用了150°的广角镜头可以大大缩小装置的尺寸,所拍摄出的图片是会有失真的所以在实际操作中必须要把失真的图片校正不然在后面的键盘的线性划分时会有线性误差而导致整个键盘定位不正确,要通过一定程序算法来校正摄像头拍摄出的曲面失真图片,图形校正采用了张正友的平面棋盘格图形校正算法为了得到摄像头的物理参数使用Matlab的相机校正工具Camera Calibration Toolbox。

http://www.vision.caltech.edu/bouguetj/calib_doc/

http://research.microsoft.com/en-us/um/people/zhang/Calib/

Step 6: Software Process

得到二值化图像后接下来要做的就是查找所有兴趣点的轮廓,OpenCV里的findContours是轮廓检测函数之一这个函数可以使用多边形来近似表示一个轮廓其次,多边形逼近的目的是为了减少轮廓的顶点数目。但多边形逼近的结果依然是一个轮廓,只是这个轮廓相对要粗旷一些。如果要使得查找的轮廓平滑一点可以使用approxPolyDP函数对该多边形曲线做适当近似,如果要画出查找到的轮廓的话就可以配合使用drawContours函数,使用函数boundingRect,还可以得到轮廓的外包络矩形。定位包络矩形的中心点在图片中的坐标然后就可以检测到手指的位置然后可以投射到键盘对应的位置。

Step 7: Test