Code Monkey home page Code Monkey logo

face-detection-using-mtcnn's Introduction

Face-detection-using-MTCNN

face detection using mtcnn complete implementation step by step

Installation

Python version should be 3.7. Run the following commands one by one sequently.

 pip install opencv-python==4.4.0.46
 
 pip install keras==2.3.1
 
 pip install tensorflow==2.2.1
 
 pip install mtcnn==0.1.0
 
 pip install numpy==1.16.6

Face Detection in Image

Run the "mtcnn_image.py" file and keep your input image in the "input & output" folder and set your image path (or name) in the "mtcnn_image.py" file. The output save in the "input & output" folder with "Outputfile.jpg" name (you can also change output file name). Test image is shown below:

Outputfile

Face Detection in .MP4 file

Run the "mtcnn_video.py" file and keep your input video in the "input & output" folder and set your image path (or name) in the "mtcnn_video.py" file. The output save in the "input & output" folder with "filename.avi" name (you can also change output file name). Test Video is shown below:

ezgif com-gif-maker

Face Detection using live camera

Run the "mtcnn_live_cam.py" file or run the following code for live face detection:

import cv2
from mtcnn.mtcnn import MTCNN
detector = MTCNN()

video = cv2.VideoCapture(0)

if (video.isOpened() == False):
    print("Web Camera not detected")
while (True):
    ret, frame = video.read()
    if ret == True:
        location = detector.detect_faces(frame)
        if len(location) > 0:
            for face in location:
                x, y, width, height = face['box']
                x2, y2 = x + width, y + height
                cv2.rectangle(frame, (x, y), (x2, y2), (0, 0, 255), 4)
        cv2.imshow("Output",frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break

video.release()
cv2.destroyAllWindows()

Live Camera Output

ezgif com-gif-maker (1)

face-detection-using-mtcnn's People

Contributors

ali-jakhar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

abhiiisc jovin247

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.