Numerical stability hotfix, attempt to fix travis CI for osx.

This commit is contained in:
Tadas Baltrusaitis
2018-05-26 08:59:11 +01:00
parent d333ba238a
commit ade0e4ecc8
3 changed files with 22 additions and 4 deletions

View File

@@ -13,7 +13,8 @@ compiler:
os:
- linux
- osx
before_install:
# OpenCV dependencies and boost

View File

@@ -9,9 +9,15 @@ set(CMAKE_CONFIG_DIR etc/OpenFace)
set(CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_CONFIG_DIR}")
add_definitions(-DCONFIG_DIR="${CONFIG_DIR}")
find_package( BLAS REQUIRED )
include_directories( ${BLAS_INCLUDE_DIRS} )
LINK_DIRECTORIES(${BLAS_LIBRARY_DIRS})
if (APPLE)
find_package( OpenBLAS REQUIRED )
include_directories( ${OpenBLAS_INCLUDE_DIRS} )
LINK_DIRECTORIES(${OpenBLAS_LIBRARY_DIRS})
else()
find_package( BLAS REQUIRED )
include_directories( ${BLAS_INCLUDE_DIRS} )
LINK_DIRECTORIES(${BLAS_LIBRARY_DIRS})
endif()
find_package( OpenCV 3.3 REQUIRED )

View File

@@ -460,6 +460,7 @@ void PDM::UpdateModelParameters(const cv::Mat_<float>& delta_p, cv::Mat_<float>&
// get the original rotation matrix
cv::Vec3f eulerGlobal(params_global[1], params_global[2], params_global[3]);
cv::Matx33f R1 = Utilities::Euler2RotationMatrix(eulerGlobal);
// construct R' = [1, -wz, wy
@@ -479,8 +480,18 @@ void PDM::UpdateModelParameters(const cv::Mat_<float>& delta_p, cv::Mat_<float>&
// Extract euler angle (through axis angle first to make sure it's legal)
cv::Vec3f axis_angle = Utilities::RotationMatrix2AxisAngle(R3);
cv::Vec3f euler = Utilities::AxisAngle2Euler(axis_angle);
// Temporary fix to numerical instability
if (isnan(euler[0]) || isnan(euler[1]) || isnan(euler[2]))
{
euler[0] = 0;
euler[1] = 0;
euler[2] = 0;
}
params_global[1] = euler[0];
params_global[2] = euler[1];
params_global[3] = euler[2];