Arduino image processing Eye Pupil Tracking, how to make Haarcascade XML file

(Last Updated On: February 5, 2022)

Eye Pupil Tracking, Image Processing based project Description:

eye pupil tracking

eye pupil tracking– A few months back I uploaded a project on “Arduino Image Processing human face recognition and Entrance control using the electronic lock, and EmguCv. In this project, we successfully detected the human face using the frontalface XML file and controlled an electronic lock. The face recognition was possible due to the frontalface XML file, I recommend you should watch this tutorial first and then you can resume from here, as today we will be using the same project. You can create your own XML files and track almost anything you want.

In this tutorial, I will practically show you how to train an XML file for tracking the eye pupil, while the same steps can be used to train an XML file for any type of object.

In today’s episode, you will learn how to make your own XML file for eye pupil tracking. Today’s episode covers

  1. Steps to make your own XML file.
  2. How to use an XML file in programming.

For the complete step-by-step explanation, watch video Tutorial given at the end.

Amazon Links:

12v Adaptor:

Arduino Uno

Arduino Nano

Mega 2560:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Eye Pupil Tracking XML file training:

For creating the Haarcascade XML file you will need software.

As I want to track blue eyes, so that’s why I download pictures having blue eyes. If you want to track brown eyes or black eyes then simply download images consisting of brown or black color eyes. Or you can also take pictures of your own eye…

eye pupil tracking

The next step is to change the format of these images, as these images are of the type jpg, let’s convert these images to BMP format using adobe photoshop. This process is really simple, simply open the image and save as the image with a different name and select BMP as the format.

eye pupil tracking

We have a total of 6 images of the type bmp.

This is the software that I will be using form making the XML file.

eye pupil tracking

Open the cascades folder and delete all of these folders…

eye pupil tracking

Now open the negative folder, this folder consists of the negative images. Negative images are those images that do not consist of the object you want to track. You can also add more negative images of the type jpg…currently this folder have 200 negative images… The bg and create_list these two files are not included. Double click the create_list file.

eye pupil tracking

Now open the positive folder then open the raw data folder, simply delete these images

eye pupil tracking

And paste the images consisting of eyes, these are the positive images.

eye pupil tracking

now click on the object maker….now select the region you want to track…then simply press the space bar key on your keyboard and then press the enter key…repeat the same steps for all the images…

eye pupil tracking

eye pupil tracking

After you are done with all the images then Double click the samples creations file, which will make a file in the vector folder, which you can check. By Default the vector folder is empty.

eye pupil tracking

Right click on the haar training and select edit with notepad…the negative images are 200…while the positive images are 6. Update the number of positive images and negative images.

eye pupil tracking

Now double click on the haar training file and wait for a while, this can take some time.

Now the last step is to double click on the converted file to make the XML file…as you can see the XML file with the name myhaar is created…

eye pupil tracking

Rename this file with the name eyepupil…

eye pupil tracking

Now, this XML file is ready and can be used with Arduino, raspberry pi, you can use this XML file with emgucv, opencv, python, etc…

eye pupil tracking

This is the same application which I designed for the image processing based entrance control system…i have already explained this project in very detailed. You can watch this tutorial “Click here link2”.

The changes I made in this application can be watched in the video given below at the end of this article.

Eye Pupil Tracking Image Processing Programming:

For software changes, watch video given below.

Watch Video Tutorial:


Other Arduino Image Processing based Projects:

OCR Optical Character recognition using and Arduino


Arduino Image processing CCTV camera system using


Arduino Image Processing based Entrance lock Control System




Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...


  1. Dear Engr Fahad,
    I enjoyed watching your video regarding eye pupil tracking. If you wouldn’t mind, I would like to speak with you about your interest and availability in creating a similar system for my use in an academic research environment. I have some specific objectives, but have no idea if you are at all interested or available to speak about this. At your convenience, sir, please contact me via email to advise. In advance of your reply, I thank you.

Leave a Reply

%d bloggers like this: