Comments (5)
Hi @codeYazar
what does it mean , especially [-2] in moments = cv2.moments(contours[-2])
The algorithm detects faces, eyes and then processes the frame to get that:
The black block is the iris. We use it to calculate the centroid (I consider that is the pupil position). First, it's necessary to detect this contour:
_, contours, _ = cv2.findContours(self.iris_frame, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
It returns a list of several contours:
- the contour of the entire frame
- the contour of the iris
- the contours of other small black blocks if the binarization was not optimal
Of course, we want to get only the iris contour. So to do that, the algorithm sorts the contours list by size:
contours = sorted(contours, key=cv2.contourArea)
The contours are now sorted from the smallest to the largest.
So the last one is the contour of the entire frame and the second to last is the contour of iris.
So we can access iris contour like so: contours[-2]
I also want to ask you how to match the coordinates on the webcam, on the PC screen.
I don't understand well your question. Do you want to use it to move your mouse?
from gazetracking.
Yeah. I want to move the mouse with my eyes. But the head will not be fixed. He should let the head move.
from gazetracking.
To have the relative coordinates of the pupils, without the position of the head having any impact, you can change:
def pupil_left_coords(self):
"""Returns the coordinates of the left pupil"""
if self.pupils_located:
x = self.eye_left.origin[0] + self.eye_left.pupil.x
y = self.eye_left.origin[1] + self.eye_left.pupil.y
return (x, y)
to
def pupil_left_coords(self):
"""Returns the coordinates of the left pupil"""
if self.pupils_located:
x = self.eye_left.pupil.x
y = self.eye_left.pupil.y
return (x, y)
from gazetracking.
I tried using horizontal_ratio and vertical_ratio to move the mouse cursor (using pyautogui library) as in,
`` X,Y = gaze.horizontal_ratio(),gaze.vertical_ratio()
w , h = pyautogui.size() #Returns the size of the screen
try:
x = int(w*X)
y = int(h*Y)
except TypeError:
x , y = None,None
print(x,y)
pyautogui.moveTo(x,y) #Moves the mouse cursor to (x,y)``
The performance isn't good. Is there any better way or a calibration technique I'm missing?
from gazetracking.
Hi @wittynerd, gaze.horizontal_ratio()
and gaze.vertical_ratio()
return ratios to know the gaze direction. It doesn't return any coordinates, and you shouldn't try to get coordinates from it. Instead, you should use gaze.pupil_left_coords()
and gaze.pupil_right_coords()
. Good luck!
from gazetracking.
Related Issues (20)
- Do i visualization about Detection model, Tracking Model?
- (Beginner Issue) What IDE should I use ? HOT 2
- Maybe turn it into a pip package?
- [Question] Scaling/Shifting Calculations in Horizontal/Vertical Ratio?
- identify persons in group looking at cam
- Algorithm
- Translate into Korean
- Could not find a version that satisfies the requirement opencv_python==4.2.0.42 HOT 3
- pybind11 issue HOT 1
- Dependency conflicts
- what alogrithm is used ? is it cnn ? HOT 1
- saving the coordinates
- Package installation error HOT 2
- Cannot find the requirements.txt file in git repo
- Problem for running the code on an input video HOT 1
- Running on gpu HOT 3
- code start issue. HOT 2
- Ratio > 1?
- GazeTracking import error HOT 2
- May I ask how to use this project to find the position of the screen where the eyes are focused HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gazetracking.