Skip to content

Recognizing actors in a movie clip or image, using OpenCV, DeepLearning and Python.

Notifications You must be signed in to change notification settings

mju-oss-project-team-shh/Actor-Recognition-In-Movies

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Actor Recognition In Movie Clips and Images

[NOTICE] This project is improved for MJU OSS class.

  • Improved console UI with console-menu
  • Uses selenium to crawl actors' images as dataset
  • Opens default file explorer for different OSs to choose the file

ex1

ex1_540

ex2_540

Recognizing actors in a movie clip or image, using DeepLearning and Python. Can use either CNN or HOG for face detection and then compare the face with our dataset of faces.

Here I've used Spiderman 2 (2004), as an example. It can work with any piece of media, given the right dataset.

Tons of help from ageitgey's face_recognition library.

Inspired by this wonderful article.

Process

  • Dataset

    The dataset has the following structure, containing actor images collected using the Bing Image API (getData.py).

    screenshot from 2019-01-11 19-19-13

    As I'm using Spiderman 2, I've collected several pictures of the actors in the movie. Per actor I have ~15 images. More will do better, but this number seems to work fine.

  • Training

    For every image in the dataset, we first get a square enclosing the face in the image, then generate a 128d vector for that face, which is dumped to the 'encodings.pickle' file.

    We can either use CNN(slower, more accurate) or HOG(faster, less accurate) for the face detection process. Here I've used the face_recognition library, which gives me both the options.

  • Face Recognition

    Consider an image, be it a still from the movie, or a frame of a video clip. First, we identify the faces in the image using the same method as above (CNN or HOG), generate an encoding for it(128d vector), and then compare it with our collected encodings. The actors with the most matched encodings is the actor in the image.

Usage

Read the first few lines of the Python file involved to understand the parameters used in each case

  • Making encodings

    python faceEncode.py --dataset dataset/actors --encodings encodings.pickle -d hog
    
  • Face Recognition in Image

    python faceRecImage.py -e encodings.pickle -i examples/ex6.png -d hog
    
  • Face Recognition in Video File

    python faceRecVideoFile.py -e encodings.pickle -i input_vids/ex2.mp4 -o output_vids/ex2.mp4 -y 0 -d hog
    

    Outputs a video with the faces marked.

  • Face Recognition in Video Stream from Webcam

    python faceRecVideo.py -e encodings.pickle -o output_vids/ex1.avi -y 0 -d hog
    
  • Getting Image Data

    python getData.py --query "tobey macguire" --output dataset/tobey_macquire
    

    Will fetch images from Bing Image Search and save in the mentioned directory (Max 50). Make sure to get your own Bing search API key from here and fill it up in the code.

Feel free to fork the repository and use it on your own movies, maybe expand the dataset and make it a general software for any given movie :)

About

Recognizing actors in a movie clip or image, using OpenCV, DeepLearning and Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 71.5%
  • Jupyter Notebook 18.2%
  • Batchfile 7.7%
  • Shell 2.6%