Moving to AVX instead of AVX2, compiler warning fixes. Losing dependency on OpenCV C style bindings for affine warping.

This commit is contained in:
Tadas Baltrusaitis
2018-05-07 21:54:52 +01:00
parent c376351145
commit e6849c6b52
182 changed files with 155 additions and 232 deletions

View File

@@ -145,7 +145,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CPPINEROP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>./;$(SolutionDir)lib\local\LandmarkDetector\include;$(SolutionDir)lib\local\FaceAnalyser\include;$(SolutionDir)lib\local\GazeAnalyser\include;$(SolutionDir)lib\local\Utilities\include;$(SolutionDir)lib\3rdParty\CameraEnumerator;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -166,7 +166,7 @@
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;CPPINEROP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>./;$(SolutionDir)lib\local\LandmarkDetector\include;$(SolutionDir)lib\local\FaceAnalyser\include;$(SolutionDir)lib\local\GazeAnalyser\include;$(SolutionDir)lib\local\Utilities\include;$(SolutionDir)lib\3rdParty\CameraEnumerator;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@@ -0,0 +1,24 @@
svm_disfa/AU_1_dynamic.dat AU01
svm_disfa/AU_2_dynamic.dat AU02
svm_disfa/AU_4_static.dat AU04
svm_disfa/AU_5_dynamic.dat AU05
svm_disfa/AU_6_static.dat AU06
svm_disfa/AU_9_dynamic.dat AU09
svm_disfa/AU_12_dynamic.dat AU12
svm_disfa/AU_15_dynamic.dat AU15
svm_disfa/AU_17_dynamic.dat AU17
svm_disfa/AU_20_dynamic.dat AU20
svm_disfa/AU_25_dynamic.dat AU25
svm_disfa/AU_26_dynamic.dat AU26
svr_disfa/AU_1_dynamic_intensity.dat AU01
svr_disfa/AU_2_dynamic_intensity.dat AU02
svr_disfa/AU_4_dynamic_intensity_comb.dat AU04
svr_disfa/AU_5_dynamic_intensity.dat AU05
svr_disfa/AU_6_dynamic_intensity_comb.dat AU06
svr_disfa/AU_9_dynamic_intensity.dat AU09
svr_disfa/AU_12_dynamic_intensity_comb.dat AU12
svr_disfa/AU_15_dynamic_intensity_comb.dat AU15
svr_disfa/AU_17_dynamic_intensity_comb.dat AU17
svr_disfa/AU_20_dynamic_intensity.dat AU20
svr_disfa/AU_25_dynamic_intensity_comb.dat AU25
svr_disfa/AU_26_dynamic_intensity_comb.dat AU26

View File

@@ -0,0 +1,24 @@
svm_disfa/AU_1_static.dat AU01
svm_disfa/AU_2_static.dat AU02
svm_disfa/AU_4_static.dat AU04
svm_disfa/AU_5_static.dat AU05
svm_disfa/AU_6_static.dat AU06
svm_disfa/AU_9_static.dat AU09
svm_disfa/AU_12_static.dat AU12
svm_disfa/AU_15_static.dat AU15
svm_disfa/AU_17_static.dat AU17
svm_disfa/AU_20_static.dat AU20
svm_disfa/AU_25_static.dat AU25
svm_disfa/AU_26_static.dat AU26
svr_disfa/AU_1_static_intensity.dat AU01
svr_disfa/AU_2_static_intensity.dat AU02
svr_disfa/AU_4_static_intensity.dat AU04
svr_disfa/AU_5_static_intensity.dat AU05
svr_disfa/AU_6_static_intensity.dat AU06
svr_disfa/AU_9_static_intensity.dat AU09
svr_disfa/AU_12_static_intensity.dat AU12
svr_disfa/AU_15_static_intensity.dat AU15
svr_disfa/AU_17_static_intensity.dat AU17
svr_disfa/AU_20_static_intensity.dat AU20
svr_disfa/AU_25_static_intensity.dat AU25
svr_disfa/AU_26_static_intensity.dat AU26

View File

@@ -0,0 +1,3 @@
AUPredictor AU_DISFA_best.txt
PDM In-the-wild_aligned_PDM_68.txt
Triangulation tris_68_full.txt

View File

@@ -0,0 +1,3 @@
AUPredictor AU_DISFA_static.txt
PDM In-the-wild_aligned_PDM_68.txt
Triangulation tris_68_full.txt

View File

@@ -141,7 +141,7 @@
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>./include;$(SolutionDir)lib/local/Utilities/include;$(SolutionDir)lib/local/LandmarkDetector/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
</ClCompile>
@@ -167,7 +167,7 @@
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>./include;$(SolutionDir)lib/local/Utilities/include;$(SolutionDir)lib/local/LandmarkDetector/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>

View File

@@ -116,7 +116,7 @@
<AdditionalIncludeDirectories>./include;../LandmarkDetector/include;../Utilities/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
</ClCompile>
<Link>
@@ -135,7 +135,7 @@
<AdditionalIncludeDirectories>./include;../LandmarkDetector/include;../Utilities/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
</ClCompile>
<Link>

View File

@@ -148,7 +148,7 @@ xcopy /I /E /Y /D "$(SolutionDir)lib\3rdParty\OpenCV3.4\classifiers" "$(OutDir)c
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OpenMPSupport>false</OpenMPSupport>
<AdditionalOptions>/Zm300 %(AdditionalOptions)</AdditionalOptions>
@@ -173,7 +173,7 @@ xcopy /I /E /Y /D "$(SolutionDir)lib\3rdParty\OpenCV3.4\classifiers" "$(OutDir)c
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OpenMPSupport>false</OpenMPSupport>
<AdditionalOptions>/Zm300 %(AdditionalOptions)</AdditionalOptions>

View File

@@ -53,8 +53,8 @@ namespace LandmarkDetector
public:
// Width and height of the patch expert support area
int width;
int height;
int width_support;
int height_support;
// Neural weights
std::vector<cv::Mat_<float>> biases;

View File

@@ -455,8 +455,7 @@ void CCNF_patch_expert::ResponseOpenBlas(const cv::Mat_<float> &area_of_interest
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 0.0;
char *nT = "N";
sgemm_(nT, nT, &normalized_input.cols, &weight_matrix.rows, &weight_matrix.cols, &alpha1, (float*)normalized_input.data, &normalized_input.cols, (float*)weight_matrix.data, &weight_matrix.cols, &beta1, (float*)neuron_resp_full.data, &normalized_input.cols);
sgemm_("N", "N", &normalized_input.cols, &weight_matrix.rows, &weight_matrix.cols, &alpha1, (float*)normalized_input.data, &normalized_input.cols, (float*)weight_matrix.data, &weight_matrix.cols, &beta1, (float*)neuron_resp_full.data, &normalized_input.cols);
// Above is a faster version of this
//cv::Mat_<float> neuron_resp_full = this->weight_matrix * normalized_input;
@@ -500,8 +499,7 @@ void CCNF_patch_expert::ResponseOpenBlas(const cv::Mat_<float> &area_of_interest
// Perform matrix multiplication in OpenBLAS (fortran call)
alpha1 = 1.0;
beta1 = 0.0;
nT = "N";
sgemm_(nT, nT, &resp_vec_f.cols, &Sigmas[s_to_use].rows, &Sigmas[s_to_use].cols, &alpha1, (float*)resp_vec_f.data, &resp_vec_f.cols, (float*)Sigmas[s_to_use].data, &Sigmas[s_to_use].cols, &beta1, (float*)out.data, &resp_vec_f.cols);
sgemm_("N", "N", &resp_vec_f.cols, &Sigmas[s_to_use].rows, &Sigmas[s_to_use].cols, &alpha1, (float*)resp_vec_f.data, &resp_vec_f.cols, (float*)Sigmas[s_to_use].data, &Sigmas[s_to_use].cols, &beta1, (float*)out.data, &resp_vec_f.cols);
// Above is a faster version of this
//cv::Mat out = Sigmas[s_to_use] * resp_vec_f;

View File

@@ -77,7 +77,7 @@
using namespace LandmarkDetector;
// Copy constructor
CEN_patch_expert::CEN_patch_expert(const CEN_patch_expert& other) : confidence(other.confidence), width(other.width), height(other.height)
CEN_patch_expert::CEN_patch_expert(const CEN_patch_expert& other) : confidence(other.confidence), width_support(other.width_support), height_support(other.height_support)
{
// Copy the layer weights in a deep way
@@ -106,8 +106,8 @@ void CEN_patch_expert::Read(ifstream &stream)
// the number of neurons for this patch
int num_layers;
stream.read((char*)&width, 4);
stream.read((char*)&height, 4);
stream.read((char*)&width_support, 4);
stream.read((char*)&height_support, 4);
stream.read((char*)&num_layers, 4);
if (num_layers == 0)
@@ -221,11 +221,11 @@ void im2colBias(const cv::Mat_<float>& input, int width, int height, cv::Mat_<fl
void CEN_patch_expert::Response(const cv::Mat_<float> &area_of_interest, cv::Mat_<float> &response)
{
int response_height = area_of_interest.rows - height + 1;
int response_width = area_of_interest.cols - width + 1;
int response_height = area_of_interest.rows - height_support + 1;
int response_width = area_of_interest.cols - width_support + 1;
cv::Mat_<float> input_col;
im2colBias(area_of_interest, width, height, input_col);
im2colBias(area_of_interest, width_support, height_support, input_col);
// Mean and standard deviation normalization
contrastNorm(input_col, response);
@@ -246,8 +246,7 @@ void CEN_patch_expert::Response(const cv::Mat_<float> &area_of_interest, cv::Mat
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 0.0;
char *nT = "N";
sgemm_(nT, nT, &resp.cols, &weight.rows, &weight.cols, &alpha1, m1, &resp.cols, m2, &weight.cols, &beta1, m3, &resp.cols);
sgemm_("N", "N", &resp.cols, &weight.rows, &weight.cols, &alpha1, m1, &resp.cols, m2, &weight.cols, &beta1, m3, &resp.cols);
// The above is a faster version of this, by calling the fortran version directly
//cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, resp.cols, weight.rows, weight.cols, 1, m1, resp.cols, m2, weight.cols, 0.0, m3, resp.cols);
@@ -507,11 +506,11 @@ void LandmarkDetector::interpolationMatrix(cv::Mat_<float>& mapMatrix, int respo
void CEN_patch_expert::ResponseSparse(const cv::Mat_<float> &area_of_interest, cv::Mat_<float> &response, cv::Mat_<float>& mapMatrix, cv::Mat_<float>& im2col_prealloc)
{
int response_height = area_of_interest.rows - height + 1;
int response_width = area_of_interest.cols - width + 1;
int response_height = area_of_interest.rows - height_support + 1;
int response_width = area_of_interest.cols - width_support + 1;
// Extract im2col but in a sparse way and contrast normalize
im2colBiasSparseContrastNorm(area_of_interest, width, height, im2col_prealloc);
im2colBiasSparseContrastNorm(area_of_interest, width_support, height_support, im2col_prealloc);
response = im2col_prealloc.t();
for (size_t layer = 0; layer < activation_function.size(); ++layer)
@@ -529,8 +528,7 @@ void CEN_patch_expert::ResponseSparse(const cv::Mat_<float> &area_of_interest, c
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 0.0;
char *nT = "N";
sgemm_(nT, nT, &resp.cols, &weight.rows, &weight.cols, &alpha1, m1, &resp.cols, m2, &weight.cols, &beta1, m3, &resp.cols);
sgemm_("N", "N", &resp.cols, &weight.rows, &weight.cols, &alpha1, m1, &resp.cols, m2, &weight.cols, &beta1, m3, &resp.cols);
// The above is a faster version of this, by calling the fortran version directly
//cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, resp.cols, weight.rows, weight.cols, 1, m1, resp.cols, m2, weight.cols, 0.0, m3, resp.cols);
@@ -585,13 +583,13 @@ void CEN_patch_expert::ResponseSparse(const cv::Mat_<float> &area_of_interest, c
void CEN_patch_expert::ResponseSparse_mirror(const cv::Mat_<float> &area_of_interest, cv::Mat_<float> &response, cv::Mat_<float>& mapMatrix, cv::Mat_<float>& im2col_prealloc)
{
int response_height = area_of_interest.rows - height + 1;
int response_width = area_of_interest.cols - width + 1;
int response_height = area_of_interest.rows - height_support + 1;
int response_width = area_of_interest.cols - width_support + 1;
cv::flip(area_of_interest, area_of_interest, 1);
// Extract im2col but in a sparse way and contrast normalize
im2colBiasSparseContrastNorm(area_of_interest, width, height, im2col_prealloc);
im2colBiasSparseContrastNorm(area_of_interest, width_support, height_support, im2col_prealloc);
response = im2col_prealloc.t();
@@ -610,8 +608,7 @@ void CEN_patch_expert::ResponseSparse_mirror(const cv::Mat_<float> &area_of_inte
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 0.0;
char *nT = "N";
sgemm_(nT, nT, &resp.cols, &weight.rows, &weight.cols, &alpha1, m1, &resp.cols, m2, &weight.cols, &beta1, m3, &resp.cols);
sgemm_("N", "N", &resp.cols, &weight.rows, &weight.cols, &alpha1, m1, &resp.cols, m2, &weight.cols, &beta1, m3, &resp.cols);
// The above is a faster version of this, by calling the fortran version directly
//cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, resp.cols, weight.rows, weight.cols, 1, m1, resp.cols, m2, weight.cols, 0.0, m3, resp.cols);
@@ -665,14 +662,14 @@ void CEN_patch_expert::ResponseSparse_mirror(const cv::Mat_<float> &area_of_inte
void CEN_patch_expert::ResponseSparse_mirror_joint(const cv::Mat_<float> &area_of_interest_left, const cv::Mat_<float> &area_of_interest_right, cv::Mat_<float> &response_left, cv::Mat_<float> &response_right, cv::Mat_<float>& mapMatrix, cv::Mat_<float>& im2col_prealloc_left, cv::Mat_<float>& im2col_prealloc_right)
{
int response_height = area_of_interest_left.rows - height + 1;
int response_width = area_of_interest_left.cols - width + 1;
int response_height = area_of_interest_left.rows - height_support + 1;
int response_width = area_of_interest_left.cols - width_support + 1;
cv::flip(area_of_interest_right, area_of_interest_right, 1);
// Extract im2col but in a sparse way and contrast normalize
im2colBiasSparseContrastNorm(area_of_interest_left, width, height, im2col_prealloc_left);
im2colBiasSparseContrastNorm(area_of_interest_right, width, height, im2col_prealloc_right);
im2colBiasSparseContrastNorm(area_of_interest_left, width_support, height_support, im2col_prealloc_left);
im2colBiasSparseContrastNorm(area_of_interest_right, width_support, height_support, im2col_prealloc_right);
cv::Mat_<float> response;
cv::vconcat(im2col_prealloc_left, im2col_prealloc_right, response);
@@ -695,8 +692,7 @@ void CEN_patch_expert::ResponseSparse_mirror_joint(const cv::Mat_<float> &area_o
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 0.0;
char *nT = "N";
sgemm_(nT, nT, &resp.cols, &weight.rows, &weight.cols, &alpha1, m1, &resp.cols, m2, &weight.cols, &beta1, m3, &resp.cols);
sgemm_("N", "N", &resp.cols, &weight.rows, &weight.cols, &alpha1, m1, &resp.cols, m2, &weight.cols, &beta1, m3, &resp.cols);
// The above is a faster version of this, by calling the fortran version directly
//cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, resp.cols, weight.rows, weight.cols, 1, m1, resp.cols, m2, weight.cols, 0.0, m3, resp.cols);

View File

@@ -563,8 +563,7 @@ namespace LandmarkDetector
float alpha = 1.0f;
float beta = 0.0f;
// Call fortran directly (faster)
char *nT = "N";
sgemm_(nT, nT, &m2_cols, &num_rows, &pre_alloc_im2col.cols, &alpha, m2, &m2_cols, m1, &pre_alloc_im2col.cols, &beta, m3, &m2_cols);
sgemm_("N", "N", &m2_cols, &num_rows, &pre_alloc_im2col.cols, &alpha, m2, &m2_cols, m1, &pre_alloc_im2col.cols, &beta, m3, &m2_cols);
// Above is equivalent to out = pre_alloc_im2col * weight_matrix;

View File

@@ -762,7 +762,8 @@ bool FaceDetectorMTCNN::DetectFaces(vector<cv::Rect_<float> >& o_regions, const
rectify(proposal_boxes_all);
// Creating proposal images from previous step detections
vector<bool> above_thresh(proposal_boxes_all.size());
vector<bool> above_thresh;
above_thresh.resize(proposal_boxes_all.size(), false);
//tbb::parallel_for(0, (int)proposal_boxes_all.size(), [&](int k) {
for (size_t k = 0; k < proposal_boxes_all.size(); ++k)
{

View File

@@ -1115,8 +1115,7 @@ float CLNF::NU_RLMS(cv::Vec6f& final_global, cv::Mat_<float>& final_local, const
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 1.0;
char *nT = "N";
sgemm_(nT, nT, &J.cols, &J_w_t.rows, &J_w_t.cols, &alpha1, (float*)J.data, &J.cols, (float*)J_w_t.data, &J_w_t.cols, &beta1, (float*)Hessian.data, &J.cols);
sgemm_("N", "N", &J.cols, &J_w_t.rows, &J_w_t.cols, &alpha1, (float*)J.data, &J.cols, (float*)J_w_t.data, &J_w_t.cols, &beta1, (float*)Hessian.data, &J.cols);
// Above is a fast (but ugly) version of
// cv::Mat_<float> Hessian = J_w_t * J + regTerm;

View File

@@ -429,8 +429,7 @@ namespace LandmarkDetector
// Get the rotation
cv::Matx22f R = AlignShapesKabsch2D_f(src_mean_normed, dst_mean_normed);
cv::Matx22f A;
cv::Mat(s * R).copyTo(A);
cv::Matx22f A = s * R;
cv::Mat_<float> aligned = (cv::Mat(cv::Mat(A) * src.t())).t();
cv::Mat_<float> offset = dst - aligned;

View File

@@ -150,8 +150,7 @@ void PDM::CalcShape3D(cv::Mat_<float>& out_shape, const cv::Mat_<float>& p_local
int p_local_cols = p_local.cols;
int princ_comp_rows = princ_comp.rows;
int princ_comp_cols = princ_comp.cols;
char *nT = "N";
sgemm_(nT, nT, &p_local_cols, &princ_comp_rows, &princ_comp_cols, &alpha1, (float*)p_local.data, &p_local_cols, (float*)princ_comp.data, &princ_comp_cols, &beta1, (float*)out_shape.data, &p_local_cols);
sgemm_("N", "N", &p_local_cols, &princ_comp_rows, &princ_comp_cols, &alpha1, (float*)p_local.data, &p_local_cols, (float*)princ_comp.data, &princ_comp_cols, &beta1, (float*)out_shape.data, &p_local_cols);
// Above is a fast (but ugly) version of
// out_shape = mean_shape + princ_comp * p_local;
@@ -639,8 +638,7 @@ void PDM::CalcParams(cv::Vec6f& out_params_global, cv::Mat_<float>& out_params_l
// Perform matrix multiplication in OpenBLAS (fortran call)
float alpha1 = 1.0;
float beta1 = 1.0;
char *nT = "N";
sgemm_(nT, nT, &J.cols, &J_w_t.rows, &J_w_t.cols, &alpha1, (float*)J.data, &J.cols, (float*)J_w_t.data, &J_w_t.cols, &beta1, (float*)Hessian.data, &J.cols);
sgemm_("N", "N", &J.cols, &J_w_t.rows, &J_w_t.cols, &alpha1, (float*)J.data, &J.cols, (float*)J_w_t.data, &J_w_t.cols, &beta1, (float*)Hessian.data, &J.cols);
// Above is a fast (but ugly) version of
// cv::Mat_<float> Hessian2 = J_w_t * J + regularisations;

View File

@@ -162,10 +162,13 @@ void Patch_experts::Response(vector<cv::Mat_<float> >& patch_expert_responses, c
sim_img_to_ref = AlignShapesWithScale_f(image_shape_2D, reference_shape_2D);
sim_ref_to_img = sim_img_to_ref.inv(cv::DECOMP_LU);
float a1 = sim_ref_to_img(0, 0);
float b1 = -sim_ref_to_img(0, 1);
cv::Mat_<float> gray_image_flt;
grayscale_image.convertTo(gray_image_flt, CV_32F);
bool use_ccnf = !this->ccnf_expert_intensity.empty();
bool use_cen = !this->cen_expert_intensity.empty();
@@ -230,8 +233,8 @@ void Patch_experts::Response(vector<cv::Mat_<float> >& patch_expert_responses, c
if (use_cen)
{
area_of_interest_width = window_size + cen_expert_intensity[scale][view_id][ind].width - 1;
area_of_interest_height = window_size + cen_expert_intensity[scale][view_id][ind].height - 1;
area_of_interest_width = window_size + cen_expert_intensity[scale][view_id][ind].width_support - 1;
area_of_interest_height = window_size + cen_expert_intensity[scale][view_id][ind].height_support - 1;
}
else if (use_ccnf)
{
@@ -245,17 +248,13 @@ void Patch_experts::Response(vector<cv::Mat_<float> >& patch_expert_responses, c
}
// scale and rotate to mean shape to reference frame
cv::Mat sim = (cv::Mat_<float>(2, 3) << a1, -b1, landmark_locations.at<float>(ind, 0), b1, a1, landmark_locations.at<float>(ind + n, 0));
cv::Mat sim = (cv::Mat_<float>(2, 3) << a1, -b1, landmark_locations.at<float>(ind, 0) - a1 * (area_of_interest_width - 1.0f) / 2.0f + b1 * (area_of_interest_width - 1.0f) / 2.0f, b1, a1, landmark_locations.at<float>(ind + n, 0) - a1 * (area_of_interest_width - 1.0f) / 2.0f - b1 * (area_of_interest_width - 1.0f) / 2.0f);
// Extract the region of interest around the current landmark location
cv::Mat_<float> area_of_interest(area_of_interest_height, area_of_interest_width);
// Using C style openCV as it does what we need
CvMat area_of_interest_o = area_of_interest;
CvMat sim_o = sim;
IplImage im_o = grayscale_image;
cvGetQuadrangleSubPix(&im_o, &area_of_interest_o, &sim_o);
cv::Mat_<float> area_of_interest(area_of_interest_height, area_of_interest_width, 0.0f);
cv::warpAffine(gray_image_flt, area_of_interest, sim, area_of_interest.size(), cv::WARP_INVERSE_MAP + CV_INTER_LINEAR);
// Get intensity response either from the SVR, CCNF, or CEN patch experts (prefer CEN as they are the most accurate so far)
if (!cen_expert_intensity.empty())
@@ -281,15 +280,14 @@ void Patch_experts::Response(vector<cv::Mat_<float> >& patch_expert_responses, c
{
// Grab mirrored area of interest
cv::Mat sim_r = (cv::Mat_<float>(2, 3) << a1, -b1, landmark_locations.at<float>(mirror_id, 0), b1, a1, landmark_locations.at<float>(mirror_id + n, 0));
// scale and rotate to mean shape to reference frame
cv::Mat sim_r = (cv::Mat_<float>(2, 3) << a1, -b1, landmark_locations.at<float>(mirror_id, 0) - a1 * (area_of_interest_width - 1.0f) / 2.0f + b1 * (area_of_interest_width - 1.0f) / 2.0f, b1, a1, landmark_locations.at<float>(mirror_id + n, 0) - a1 * (area_of_interest_width - 1.0f) / 2.0f - b1 * (area_of_interest_width - 1.0f) / 2.0f);
// Extract the region of interest around the current landmark location
cv::Mat_<float> area_of_interest_r(area_of_interest_height, area_of_interest_width);
// Using C style openCV as it does what we need
CvMat area_of_interest_o_r = area_of_interest_r;
CvMat sim_o_r = sim_r;
IplImage im_o_r = grayscale_image;
cvGetQuadrangleSubPix(&im_o_r, &area_of_interest_o_r, &sim_o_r);
cv::Mat_<float> area_of_interest_r(area_of_interest_height, area_of_interest_width, 0.0f);
cv::warpAffine(gray_image_flt, area_of_interest_r, sim_r, area_of_interest_r.size(), cv::WARP_INVERSE_MAP + CV_INTER_LINEAR);
cv::Mat_<float> prealloc_mat_right = preallocated_im2col[mirror_id][im2col_size];

View File

@@ -126,7 +126,7 @@
<AdditionalIncludeDirectories>./include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -147,7 +147,7 @@
<AdditionalIncludeDirectories>./include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>