Skip to content

Commit

Permalink
Removing TBB dependency (#590)
Browse files Browse the repository at this point in the history
Removing a TBB dependence for code parallelization (done through OpenCV's parralel_for_
  • Loading branch information
TadasBaltrusaitis authored Oct 20, 2018
1 parent 40af2cb commit 77eae16
Show file tree
Hide file tree
Showing 176 changed files with 276 additions and 45,762 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ branches:
- master
- develop
- feature/code_cleanup
- feature/parallel_for
compiler:
- gcc

Expand Down Expand Up @@ -46,7 +47,7 @@ before_install:
- if [ "$CXX" = "g++" ]; then
if [ ${TRAVIS_OS_NAME} = linux ]; then
$CXX --version;
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_V4L=ON -D WITH_OPENCL=OFF -D INSTALL_C_EXAMPLES=OFF -D BUILD_EXAMPLES=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=OFF ..;
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_V4L=ON -D WITH_OPENCL=OFF -D INSTALL_C_EXAMPLES=OFF -D WITH_TBB=ON -D BUILD_EXAMPLES=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=OFF ..;
sudo make -j4;
sudo make install;
cd ../..;
Expand Down
19 changes: 0 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,6 @@ else()
MESSAGE(FATAL_ERROR "Boost not found in the system.")
endif()

# Try finding TBB in default location
find_package( TBB CONFIG )

# If not found, use FindTBB.cmake
if ("${TBB_LIBRARIES}" STREQUAL "")
MESSAGE("TBB not found in CONFIG, searching with FindTBB.cmake.")
find_package( TBB REQUIRED )
if ("${TBB_LIBRARIES}" STREQUAL "")
MESSAGE(FATAL_ERROR "TBB not found")
endif()
else()
MESSAGE("TBB found in CONFIG: ${TBB_LIBRARIES}")
endif()

MESSAGE("TBB information:")
MESSAGE(" TBB_VERSION: ${TBB_VERSION}")
MESSAGE(" TBB_INCLUDE_DIRS: ${TBB_INCLUDE_DIRS}")
MESSAGE(" TBB_LIBRARIES: ${TBB_LIBRARIES}")

# Move LandmarkDetector model
file(GLOB files "lib/local/LandmarkDetector/model/*.txt")
foreach(file ${files})
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ I did my best to make sure that the code runs out of the box but there are alway

Copyright can be found in the Copyright.txt

You have to respect boost, TBB, dlib, OpenBLAS, and OpenCV licenses.
You have to respect boost, dlib, OpenBLAS, and OpenCV licenses.

Furthermore you have to respect the licenses of the datasets used for model training - https:/TadasBaltrusaitis/OpenFace/wiki/Datasets
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ branches:
- develop
- master
- feature/code_cleanup
- feature/parallel_for
max_jobs: 4
configuration:
- Release
Expand Down
2 changes: 0 additions & 2 deletions exe/FaceLandmarkImg/FaceLandmarkImg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@

#include "LandmarkCoreIncludes.h"

#include <tbb/tbb.h>

#include <FaceAnalyser.h>
#include <GazeEstimation.h>

Expand Down
4 changes: 0 additions & 4 deletions exe/FaceLandmarkImg/FaceLandmarkImg.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,27 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
Expand Down
4 changes: 0 additions & 4 deletions exe/FaceLandmarkVid/FaceLandmarkVid.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,27 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
Expand Down
12 changes: 5 additions & 7 deletions exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,11 @@ int main(int argc, char **argv)

}

// Keep only non overlapping detections (also convert to a concurrent vector
// Keep only non overlapping detections (so as not to start tracking where the face is already tracked)
NonOverlapingDetections(face_models, face_detections);

vector<tbb::atomic<bool> > face_detections_used(face_detections.size());
std::vector<bool> face_detections_used(face_detections.size(), false);

// Go through every model and update the tracking
//tbb::parallel_for(0, (int)face_models.size(), [&](int model) {
for (unsigned int model = 0; model < face_models.size(); ++model)
{

Expand All @@ -288,9 +286,10 @@ int main(int argc, char **argv)

for (size_t detection_ind = 0; detection_ind < face_detections.size(); ++detection_ind)
{
// if it was not taken by another tracker take it (if it is false swap it to true and enter detection, this makes it parallel safe)
if (face_detections_used[detection_ind].compare_and_swap(true, false) == false)
// if it was not taken by another tracker take it
if (!face_detections_used[detection_ind])
{
face_detections_used[detection_ind] = true;

// Reinitialise the model
face_models[model].Reset();
Expand All @@ -314,7 +313,6 @@ int main(int argc, char **argv)
detection_success = LandmarkDetector::DetectLandmarksInVideo(rgb_image, face_models[model], det_parameters[model], grayscale_image);
}
}
//});

// Keeping track of FPS
fps_tracker.AddFrame();
Expand Down
4 changes: 0 additions & 4 deletions exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,27 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
Expand Down
4 changes: 0 additions & 4 deletions exe/FeatureExtraction/FeatureExtraction.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,27 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\boost\boost_d.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb_d.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\lib\3rdParty\boost\boost.props" />
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
<Import Project="..\..\lib\3rdParty\tbb\tbb.props" />
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS.props" />
<Import Project="..\..\lib\3rdParty\OpenCV3.4\openCV3.4.props" />
</ImportGroup>
Expand Down
Loading

0 comments on commit 77eae16

Please sign in to comment.