Skip to content

Gaze controlled keyboard · Tutorials

Virtual Keyboard 3 – Gaze controlled keyboard with Python and Opencv p.7

Access community, courses and source codes
Logo

AI Vision Academy

Access the code of this tutorial, computer vision courses and an exclusive community on AI Vision Academy

  • Access to over 50+ source codes from Pysource.com/blog
  • Dedicated video courses about computer vision
  • Access to an exclusive community of professionals
  • Real-World AI Projects – Get hands-on experience building practical AI Computer Vision solutions with a structured path.
  • Monthly Coaching Calls – get support and any of your questions answered

Subscribe to our newsletter to learn more

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)

One comment

  1. gaze_controlled_keyboard_p7.py”, line 146, in
    frame = cv2.resize(frame, None, fx=0.5, fy=0.5)
    Kindly can you solve this error
    cv2.error: OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp:3720: error: (-215:Assertion failed) !ssize.empty() in function ‘cv::resize’

Join the discussion