Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to move mouse by detected face and eye using opencv

import cv2
import sys
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
video_capture = cv2.VideoCapture(0)
while True:
    ret, img = video_capture.read()
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    Face = face_cascade.detectMultiScale(gray, 1.3, 5)
    for (x,y,w,h) in Face:
         cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),2)
         roi_gray = gray[y:y+h, x:x+w]
         roi_color = img[y:y+h, x:x+w]
         eyes = eye_cascade.detectMultiScale(roi_gray)
         for (ex,ey,ew,eh) in eyes:
             cv2.rectangle(roi_color,(ex,ey), (ex+ew,ey+eh), (0,255,0), 2)
   # Display the resulting frame
   cv2.imshow('Face and Eye Detected', img)
   if cv2.waitKey(1) & 0xFF == ord('q'):
        break
#cv2.waitKey(0)
video_capture.release()
cv2.destroyAllWindows()
Comment

PREVIOUS NEXT
Code Example
::  
Python ::  
:: python sqlite select where 
:: get parent keys of keys python 
:: install python glob module in MacOS using pip 
:: counter and element of list for loop python 
:: Loading data from Oracle Database to pandas DataFrames 
:: How to srape all links from a website in python 
::  
Python ::  
::  
Python :: how to extract a list of values from numpy array using index list 
::  
Python ::  
:: search recurse sub-folders using glob.glob module python 
::  
:: Python __div__ magic method 
::  
::  
:: python subprocess redirect a file 
::  
:: penggunaan values di python 
::  
::  
Python :: create multiple marks python for python 
:: multiply each element by x in python 
::  
Python ::  
::  
::  
ADD CONTENT
Topic
Content
Source link
Name
5+4 =