Skip to content

Commit

Permalink
Bug fix with processing really short sequences with FeatureExtraction…
Browse files Browse the repository at this point in the history
… executable
  • Loading branch information
TadasBaltrusaitis committed Jun 28, 2018
1 parent a127ec6 commit 3c9ee1c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ before_install:
# OpenCV dependencies, dlib and boost
- if [ ${TRAVIS_OS_NAME} = linux ]; then
sudo apt-get update;
sudo apt-get install libopenblas-dev libopenblas-base;
sudo apt-get install libopenblas-dev;
sudo apt-get install git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev;
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev;
sudo apt-get install cmake;
Expand Down
22 changes: 18 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Description: Install everything necessary for OpenFace to compile.
# Author: Daniyal Shahrokhian <[email protected]>
# Date: 20170428
# Version : 1.01
# Version : 1.02
# Usage: bash install.sh
# NOTES: There are certain steps to be taken in the system before installing
# via this script (refer to README): Run
Expand All @@ -27,12 +27,10 @@ fi
echo "Installing Essential dependencies..."
sudo apt-get -y update
sudo apt-get -y install build-essential
sudo apt-get -y install llvm
sudo apt-get -y install clang-3.7 libc++-dev libc++abi-dev
sudo apt-get -y install cmake
sudo apt-get -y install libopenblas-dev liblapack-dev
sudo apt-get -y install git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get -y install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev checkinstall
sudo apt-get -y install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
echo "Essential dependencies installed."

# OpenCV Dependency
Expand All @@ -51,6 +49,22 @@ rm 3.4.0.zip
sudo rm -r opencv-3.4.0
echo "OpenCV installed."

# dlib dependecy
echo "Downloading dlib"
wget http://dlib.net/files/dlib-19.13.tar.bz2;
tar xf dlib-19.13.tar.bz2;
cd dlib-19.13;
mkdir -p build;
cd build;
echo "Installing dlib"
cmake ..;
cmake --build . --config Release;
sudo make install;
sudo ldconfig;
cd ../..;
rm -r dlib-19.13.tar.bz2
echo "dlib installed"

# Boost C++ Dependency
echo "Installing Boost..."
sudo apt-get install libboost-all-dev
Expand Down
34 changes: 19 additions & 15 deletions lib/local/FaceAnalyser/src/FaceAnalyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ void FaceAnalyser::PostprocessPredictions()
{
int success_ind = 0;
int all_ind = 0;
int all_frames_size = timestamps.size();
int all_frames_size = (int)timestamps.size();

while(all_ind < all_frames_size && success_ind < max_init_frames)
{
Expand Down Expand Up @@ -616,14 +616,14 @@ void FaceAnalyser::ExtractAllPredictionsOfflineReg(vector<std::pair<std::string,
{
if (au_name.compare(dyn_au_names[a]) == 0)
{
au_id = a;
au_id = (int)a;
}
}

if (au_id != -1 && AU_SVR_dynamic_appearance_lin_regressors.GetCutoffs()[au_id] != -1)
{
double cutoff = AU_SVR_dynamic_appearance_lin_regressors.GetCutoffs()[au_id];
offsets.push_back(au_good.at((double)au_good.size() * cutoff));
offsets.push_back(au_good.at((int)((double)au_good.size() * cutoff)));
}
else
{
Expand Down Expand Up @@ -703,22 +703,26 @@ void FaceAnalyser::ExtractAllPredictionsOfflineClass(vector<std::pair<std::strin
// Perform a moving average of 7 frames on classifications
int window_size = 7;
vector<double> au_vals_tmp = au_vals;
for (size_t i = (window_size - 1)/2; i < au_vals.size() - (window_size - 1) / 2; ++i)
if(au_vals.size() > (window_size - 1) / 2)
{
double sum = 0;
for (int w = -(window_size - 1) / 2; w <= (window_size - 1) / 2; ++w)
for (size_t i = (window_size - 1)/2; i < au_vals.size() - (window_size - 1) / 2; ++i)
{
sum += au_vals_tmp[i + w];
}
sum = sum / window_size;
if (sum < 0.5)
sum = 0;
else
sum = 1;
double sum = 0;
int div_by = 0;
for (int w = -(window_size - 1) / 2; w <= (window_size - 1) / 2 && (i+w < au_vals_tmp.size()); ++w)
{
sum += au_vals_tmp[i + w];
div_by++;
}
sum = sum / div_by;
if (sum < 0.5)
sum = 0;
else
sum = 1;

au_vals[i] = sum;
au_vals[i] = sum;
}
}

au_predictions.push_back(std::pair<string,vector<double>>(au_name, au_vals));

}
Expand Down

0 comments on commit 3c9ee1c

Please sign in to comment.