Skip to content

Commit

Permalink
Merge pull request #115 from AIRLegend/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AIRLegend authored Sep 1, 2021
2 parents db25693 + e870d79 commit fba4fb6
Show file tree
Hide file tree
Showing 19 changed files with 526 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,8 @@ healthchecksdb
Client/models
prefs.ini
log.txt

# CMake
CMakeCache.txt
CMakeFiles/

39 changes: 39 additions & 0 deletions AITrack.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ALL_BUILD", "ALL_BUILD.vcxproj", "{98930F42-E1C2-387F-91F1-35E73D7EAEEF}"
ProjectSection(ProjectDependencies) = postProject
{D5A8598B-8776-3340-8582-7FAFBB98849E} = {D5A8598B-8776-3340-8582-7FAFBB98849E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{D5A8598B-8776-3340-8582-7FAFBB98849E}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
MinSizeRel|x64 = MinSizeRel|x64
RelWithDebInfo|x64 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{98930F42-E1C2-387F-91F1-35E73D7EAEEF}.Debug|x64.ActiveCfg = Debug|x64
{98930F42-E1C2-387F-91F1-35E73D7EAEEF}.Release|x64.ActiveCfg = Release|x64
{98930F42-E1C2-387F-91F1-35E73D7EAEEF}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{98930F42-E1C2-387F-91F1-35E73D7EAEEF}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{D5A8598B-8776-3340-8582-7FAFBB98849E}.Debug|x64.ActiveCfg = Debug|x64
{D5A8598B-8776-3340-8582-7FAFBB98849E}.Debug|x64.Build.0 = Debug|x64
{D5A8598B-8776-3340-8582-7FAFBB98849E}.Release|x64.ActiveCfg = Release|x64
{D5A8598B-8776-3340-8582-7FAFBB98849E}.Release|x64.Build.0 = Release|x64
{D5A8598B-8776-3340-8582-7FAFBB98849E}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{D5A8598B-8776-3340-8582-7FAFBB98849E}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{D5A8598B-8776-3340-8582-7FAFBB98849E}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{D5A8598B-8776-3340-8582-7FAFBB98849E}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C29C1D66-F65E-3F52-B3A8-FF3673057EF7}
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
27 changes: 24 additions & 3 deletions AITracker/src/PositionSolver.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
#include "PositionSolver.h"


PositionSolver::PositionSolver(int width, int height,
float prior_pitch, float prior_yaw, float prior_distance, bool complex, float fov) :
PositionSolver::PositionSolver(
int width,
int height,
float prior_pitch,
float prior_yaw,
float prior_distance,
bool complex,
float fov,
float x_scale,
float y_scale,
float z_scale) :

//TODO: Refactor removing prior_yaw/pitch parameters
landmark_points_buffer(complex ? NB_CONTOUR_POINTS_COMPLEX: NB_CONTOUR_POINTS_BASE, 1, CV_32FC2),
rv({ 0, 0, 0 }),
tv({ 0, 0, 0 })
{
this->prior_pitch = -1.57;
this->prior_yaw = -1.57;
this->prior_distance = prior_distance * -1.;
this->prior_distance = prior_distance * -2.;

this->rv[0] = this->prior_pitch;
this->rv[1] = this->prior_yaw;
this->rv[2] = -1.57;
this->tv[2] = this->prior_distance;

head3dScale = (cv::Mat_<double>(3, 3) <<
x_scale, 0.0, 0,
0.0, y_scale, 0,
0.0, 0.0, z_scale
);

this->complex = complex;

if (!complex)
Expand Down Expand Up @@ -110,6 +126,8 @@ PositionSolver::PositionSolver(int width, int height,

camera_distortion = (cv::Mat_<double>(4, 1) << 0, 0, 0, 0);

mat3dcontour = mat3dcontour * head3dScale;

if(complex) std::cout << "Using complex solver" << std::endl;
}

Expand Down Expand Up @@ -149,6 +167,9 @@ void PositionSolver::solve_rotation(FaceData* face_data)
face_data->translation[i] = tvec.at<double>(i, 0) * 10;
}

// We dont want the Z axis oversaturated.
face_data->translation[2] /= 100;

std::cout << face_data->to_string() << std::endl;

correct_rotation(*face_data);
Expand Down
6 changes: 5 additions & 1 deletion AITracker/src/PositionSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class PositionSolver
float prior_yaw = -2.f,
float prior_distance = -1.f,
bool complex = false,
float fov = 56.0f );
float fov = 56.0f,
float x_scale = 1.0f,
float y_scal = 1.0f,
float z_scale = 1.0f);

/**
Stores solved translation/rotation on the face_data object
Expand All @@ -42,6 +45,7 @@ class PositionSolver
cv::Mat mat3dface;
cv::Mat mat3dcontour;
std::vector<int> contour_indices; // Facial landmarks that interest us
cv::Mat head3dScale; // This will let us scale the 3d model so a better PnP can be acomplished

//Buffer so we dont have to allocate a list on every solve_rotation call.
cv::Mat landmark_points_buffer;
Expand Down
Loading

0 comments on commit fba4fb6

Please sign in to comment.