In the previous tutorial we learn how to create and display a virtual keyboard using opencv.

We have now two files, a main.py file where we have the code for detecting the blinking and the gaze of our eyes, and we have a file where we have the code of our visual keyboard.

To simplify all this, we’re going to put everything into a single file and create functions where the same code is repeated.
All this steps are explained in the video.

I’m going to show in this post only the new feature that we added in this tutorial, and it is the lighting up of the letters.

Light up letters each 10 frames

Basically we are lighting up a letter for 10 frames, and after that we light up the next one, so that when we reach the letter we want to press, we simply close our eyes and it gets pressed.

# Letters
if frames == 10:
	letter_index += 1
	frames = 0
if letter_index == 15:
	letter_index = 0


for i in range(15):
	if i == letter_index:
		light = True
	else:
		light = False
	letter(i, keys_set_1[i], light)