项目作者: wizut-cvlab

项目描述 :
Compare dlib shape predictor on thermal and normal images
高级语言: Python
项目地址: git://github.com/wizut-cvlab/thermal-dlib-shape-predictor.git
创建时间: 2019-09-19T09:21:15Z
项目社区:https://github.com/wizut-cvlab/thermal-dlib-shape-predictor

开源协议:MIT License

下载


Compare dlib shape detector on images in diferent spectrums

In this project we train dlib shape predictor to predict face shapes on thermal images. We want to compare our predictor with common using face shape prediction which was train on normal images (visible spectrum).

For face detection we use simple Haar-like features cascade.

Runing scripts

Dependencies:

  1. pip install numpy
  2. pip install opencv-python
  3. pip install imutils
  4. pip install dlib

For dlib installation you may need to install several additional tools, like cmake and Visual Studio build tools.

Runing:

  1. py .\run.py

Images dataset

Inside folder /images we assume exist several folders for different models. On each folder may exist various pair images - Thermal and RGB, in the same size. The name for each images consist of 4-letter image identiefier, and suffix indicating image type.

All image datasets is located into images.7z archive. The archive is located on: https://cvlab.zut.edu.pl/thermal-dlib-shape-predictor/images.7z

Predictors

Due to the large size of the files, please download and unzip predictors in application root folder:
https://cvlab.zut.edu.pl/thermal-dlib-shape-predictor/predictors.7z

Results

The scripts for each image Pari return following summary:

  1. #004 #003 [3.5686937077518217, 0.0, 13.0]

It means, in folder #004, comparing images #003, face shape prediction has:
-mean distance 3.5686937077518217,
-0.0 minimum distance,
-13.0 maximum distance,
between two corresponding shape points. Distance is expressed in pixels.

There is 4 results file:

  • results-manual.txt contains results of manula face marking on Thermal images,
  • results-thermal.txt contains results of cascade of thermal faces,
  • results-visual.txt contains results, when for prediction thermal shape we use face cascade generated on visual image.
  • results-pointsDistances.txt contains calculated distances, for every 68point from all images
  • results-normalizationParams.txt contains calculated distances used to normalization data

podsumowanie.xlsx is additional Excel file with summary results and polish labels.

In results folder, there is manual-boxes.txt file, where listed manual face marking box coordinates.

Inside scirpts

scripts/draw_shape.py

Function draw_shape gets:

  1. img, - image in grayscales to detect and predict face shape
  2. cascade, - xml with Haar like feature cascade detector
  3. predictor, - trained dlib shape predictor
  4. show - flag, toggle display image in window (default set to false)
  5. manualMarking - flag, allows to Manual marking face (instead using Haar cascade)(default set to false)
  6. box - Coordinates of detected face (from different visual spectrum or file) (default set to None)

Function return shape object as numpy array of 68 facial feature points, and box array contains coordinates of detected face, or empty array, when there is no face detection.
normalizationParams returns 2 values, distances between the outer eye corners (points 36 and 45) and diagonal of the bounding box.

scripts/compare_files.py

For pair of thermal and visual images, function compare_files calculates distances (in pixels) between shapes predicted in draw_shape function.

scripts/face_detect.py

Legacy script. Allow to generate detection video file.