Commit 48d44c4c authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Integrated PolaThermal dataset

parent e854e786
Pipeline #49550 failed with stage
in 6 minutes and 14 seconds
from import PolaThermalDatabase
# In case protocol is comming from chain loading
if "protocol" not in locals():
protocol = "VIS-thermal-overall-split1""
database = PolaThermalDatabase(protocol=protocol)
......@@ -9,12 +9,13 @@ from .gbu import GBUBioDatabase
from .arface import ARFaceBioDatabase
from .lfw import LFWBioDatabase
from .multipie import MultipieDatabase
from .ijbc import IJBCBioDatabase
from .ijbc import IJBCDatabase, IJBCBioDatabase
from .replaymobile import ReplayMobileBioDatabase
from .fargo import FargoBioDatabase
from .meds import MEDSDatabase
from .morph import MorphDatabase
from .casia_africa import CasiaAfricaDatabase
from .pola_thermal import PolaThermalDatabase
# gets sphinx autodoc done right - don't remove it
......@@ -43,11 +44,12 @@ __appropriate__(
__all__ = [_ for _ in dir() if not _.startswith("_")]
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Tiago de Freitas Pereira <>
PolaThermal database: database implementation
from import CSVDataset
from import CSVToSampleLoaderBiometrics
from import EyesAnnotations
from bob.extension import rc
from import get_file
from sklearn.pipeline import make_pipeline
class PolaThermalDatabase(CSVDataset):
Collected by USA Army, the Polarimetric Thermal Database contains basically VIS and Thermal face images.
Follow bellow the description of the imager used to capture this device.
The **polarimetric** LWIR imager used to collect this database was developed by Polaris Sensor Technologies.
The imager is based on the division-of-time spinning achromatic retarder (SAR) design that uses a spinning phase-retarder mounted in series with a linear wire-grid polarizer.
This system, also referred to as a polarimeter, has a spectral response range of 7.5-11.1, using a Stirling-cooled mercury telluride focal plane array with pixel array dimensions of 640×480.
A Fourier modulation technique is applied to the pixel readout, followed by a series expansion and inversion to compute the Stokes images.
Data were recorded at 60 frames per second (fps) for this database, using a wide FOV of 10.6°×7.9°. Prior to collecting data for each subject, a two-point non-uniformity correction (NUC) was performed using a Mikron blackbody at 20°C and 40°C, which covers the range of typical facial temperatures (30°C-35°C).
Data was recorded on a laptop using custom vendor software.
An array of four Basler Scout series cameras was used to collect the corresponding **visible spectrum imagery**.
Two of the cameras are monochrome (model # scA640-70gm), with pixel array dimensions of 659×494.
The other two cameras are color (model # scA640-70gc), with pixel array dimensions of 658×494.
The dataset contains 60 subjects in total.
For **VIS** images (considered only the 87 pixels interpupil distance) there are 4 samples per subject with neutral expression (called baseline condition **B**) and 12 samples per subject varying the facial expression (called expression **E**).
Such variability was introduced by asking the subject to count orally.
In total there are 960 images for this modality.
For the **thermal** images there are 4 types of thermal imagery based on the Stokes parameters (:math:`S_0`, :math:`S_1`, :math:`S_2` and :math:`S_3`) commonly used to represent the polarization state.
The thermal imagery is the following:
- :math:`S_0`: The conventional thermal image
- :math:`S_1`
- :math:`S_2`
- DoLP: The degree-of-linear-polarization (DoLP) describes the portion of an electromagnetic wave that is linearly polarized, as defined :math:`\\frac{sqrt(S_{1}^{2} + S_{2}^{2})}{S_0}`.
Since :math:`S_3` is very small and usually taken to be zero, the authors of the database decided not to provide this part of the data.
The same facial expression variability introduced in **VIS** is introduced for **Thermal** images.
The distance between the subject and the camera is the last source of variability introduced in the thermal images.
There are 3 ranges: R1 (2.5m), R2 (5m) and R3 (7.5m).
In total there are 11,520 images for this modality and for each subject they are split as the following:
| Imagery/Range | R1 (B/E) | R2 (B/E) | R3 (B/E) |
| :math:`S_0` | 16 (8/8) | 16 (8/8) | 16 (8/8) |
| :math:`S_1` | 16 (8/8) | 16 (8/8) | 16 (8/8) |
| :math:`S_2` | 16 (8/8) | 16 (8/8) | 16 (8/8) |
| DoLP | 16 (8/8) | 16 (8/8) | 16 (8/8) |
.. warning::
Use the command below to set the path of the real data::
$ bob config set [PATH-TO-MEDS-DATA]
protocol: str
One of the database protocols.
def __init__(self, protocol):
# Downloading model if not exists
urls = PolaThermalDatabase.urls()
filename = get_file(
"pola_thermal.tar.gz", urls, file_hash="cfbd7362773c6d49292fe1998e3c3825",
self.annotation_type = "eyes-center"
self.fixed_positions = None
directory = (
if rc[""]
else ""
def load(path):
Images in this dataset are stored as 16-bit PNG
return / 255
def protocols():
# TODO: Until we have (if we have) a function that dumps the protocols, let's use this one.
return [
def urls():
return [
......@@ -404,3 +404,12 @@ def test_casia_africa():
assert len(database.references()) == 2455
assert len(database.probes()) == 2426
def test_casia_polathermal():
from import PolaThermalDatabase
database = PolaThermalDatabase("VIS-thermal-overall-split1")
assert len(database.references()) == 35
assert len(database.probes()) == 1680
......@@ -23,6 +23,7 @@ Databases
Face Image Annotators
......@@ -113,6 +113,7 @@ setup(
"meds =",
"morph =",
"casia-africa =",
"pola-thermal =",
"": [
"facedetect =",
......@@ -179,6 +180,7 @@ setup(
"meds =",
"morph =",
"casia-africa =",
"pola-thermal =",
"resnet50-msceleb-arcface-2021 =",
"resnet50-vgg2-arcface-2021 =",
"mobilenetv2-msceleb-arcface-2021 =",
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment