Created
September 14, 2014 03:37
-
-
Save edfungus/8da9baa0a04aa6d59177 to your computer and use it in GitHub Desktop.
OpenCV - eye tracking of webcam video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
import time | |
cap = cv2.VideoCapture(0) #640,480 | |
w = 640 | |
h = 480 | |
while(cap.isOpened()): | |
ret, frame = cap.read() | |
if ret==True: | |
#detect face | |
faces = cv2.CascadeClassifier('haarcascade_eye.xml') | |
detected = faces.detectMultiScale(frame, 1.3, 5) | |
#draw square | |
for (x,y,w,h) in detected: | |
cv2.rectangle(frame, (x,y), ((x+w),(y+h)), (0,0,255),1) | |
cv2.line(frame, (x,y), ((x+w,y+h)), (0,0,255),1) | |
cv2.line(frame, (x+w,y), ((x,y+h)), (0,0,255),1) | |
#cv2.rectangle(frame, (x,y),((x+40),(y+40)),(0,0,255),1) | |
#show picture | |
cv2.imshow('frame',frame) | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break | |
else: | |
break | |
# Release everything if job is finished | |
cap.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
This works ok if there is only one face and no other black objects.
It shows wrong identification for photo or id cards. .....