Face Detection Using Python and OpenCV Library

3,432

23

3

Introduction: Face Detection Using Python and OpenCV Library

This project will use the OpenCV library and python to facilitate face detection

Step 1: What You Need

1. An Intel Edison Development Board

2. A webcam, we will use the Light Wave LW-IC500

3. Python and the openCV library installed on your machine

Step 2: Setting Up

The Intel Edison board has an inbuilt USB port, through which you can connect your webcam. This will provide power and get images from the camera.

Also, connect the Edison to your computer through the provided USB Cable in order to upload programs. Make sure your putty is running well, and is connected to the board

Step 3: Your Code:

import numpy
import cv2 import urllib print("Downloading Images and Necessary Files") urllib.urlretrieve('http://cdn.makezine.com/make/43/Intel_CES_Team.png', '/usr/lib/edison_config_tools/public/in.jpg') urllib.urlretrieve('https://raw.githubusercontent.com/Itseez/opencv/master/data/haarcascades/haarcascade_frontalface_alt.xml', '/usr/lib/edison_config_tools/public/haarcascade_frontalface_alt.xml') img = cv2.imread('/usr/lib/edison_config_tools/public/in.jpg') gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) faceCascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml') faces = faceCascade.detectMultiScale(gray,scaleFactor=1.1,minNeighbors=5,minSize=(30, 30), flags = cv2.cv.CV_HAAR_SCALE_IMAGE) for (x,y,w,h) in faces: cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) cv2.imwrite('in_face_found.png',img)

Step 4: Try It Out

Log on to your html page and check the results out

Be the First to Share

    Recommendations

    • Mason Jar Speed Challenge

      Mason Jar Speed Challenge
    • Bikes Challenge

      Bikes Challenge
    • Remix Contest

      Remix Contest

    3 Discussions

    0
    noorthamer
    noorthamer

    3 years ago

    hello sir ^^
    please do you have the algorithim of object track by python ??

    0
    seamster
    seamster

    5 years ago on Introduction

    Very interesting, thanks!

    Would you use a face detection feature like this for security purposes, or for something else?

    0
    robopathshala
    robopathshala

    Reply 3 years ago

    https://www.instructables.com/id/Face-Detectionrecognition/