Skip to content

Commit fba4fb6

Browse files
authored
Merge pull request #115 from AIRLegend/dev
Dev
2 parents db25693 + e870d79 commit fba4fb6

19 files changed

+526
-13
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,8 @@ healthchecksdb
349349
Client/models
350350
prefs.ini
351351
log.txt
352+
353+
# CMake
354+
CMakeCache.txt
355+
CMakeFiles/
356+

AITrack.sln

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ALL_BUILD", "ALL_BUILD.vcxproj", "{98930F42-E1C2-387F-91F1-35E73D7EAEEF}"
5+
ProjectSection(ProjectDependencies) = postProject
6+
{D5A8598B-8776-3340-8582-7FAFBB98849E} = {D5A8598B-8776-3340-8582-7FAFBB98849E}
7+
EndProjectSection
8+
EndProject
9+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{D5A8598B-8776-3340-8582-7FAFBB98849E}"
10+
ProjectSection(ProjectDependencies) = postProject
11+
EndProjectSection
12+
EndProject
13+
Global
14+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
15+
Debug|x64 = Debug|x64
16+
Release|x64 = Release|x64
17+
MinSizeRel|x64 = MinSizeRel|x64
18+
RelWithDebInfo|x64 = RelWithDebInfo|x64
19+
EndGlobalSection
20+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21+
{98930F42-E1C2-387F-91F1-35E73D7EAEEF}.Debug|x64.ActiveCfg = Debug|x64
22+
{98930F42-E1C2-387F-91F1-35E73D7EAEEF}.Release|x64.ActiveCfg = Release|x64
23+
{98930F42-E1C2-387F-91F1-35E73D7EAEEF}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
24+
{98930F42-E1C2-387F-91F1-35E73D7EAEEF}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
25+
{D5A8598B-8776-3340-8582-7FAFBB98849E}.Debug|x64.ActiveCfg = Debug|x64
26+
{D5A8598B-8776-3340-8582-7FAFBB98849E}.Debug|x64.Build.0 = Debug|x64
27+
{D5A8598B-8776-3340-8582-7FAFBB98849E}.Release|x64.ActiveCfg = Release|x64
28+
{D5A8598B-8776-3340-8582-7FAFBB98849E}.Release|x64.Build.0 = Release|x64
29+
{D5A8598B-8776-3340-8582-7FAFBB98849E}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
30+
{D5A8598B-8776-3340-8582-7FAFBB98849E}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
31+
{D5A8598B-8776-3340-8582-7FAFBB98849E}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
32+
{D5A8598B-8776-3340-8582-7FAFBB98849E}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
33+
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {C29C1D66-F65E-3F52-B3A8-FF3673057EF7}
36+
EndGlobalSection
37+
GlobalSection(ExtensibilityAddIns) = postSolution
38+
EndGlobalSection
39+
EndGlobal

AITracker/src/PositionSolver.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
11
#include "PositionSolver.h"
22

33

4-
PositionSolver::PositionSolver(int width, int height,
5-
float prior_pitch, float prior_yaw, float prior_distance, bool complex, float fov) :
4+
PositionSolver::PositionSolver(
5+
int width,
6+
int height,
7+
float prior_pitch,
8+
float prior_yaw,
9+
float prior_distance,
10+
bool complex,
11+
float fov,
12+
float x_scale,
13+
float y_scale,
14+
float z_scale) :
15+
616
//TODO: Refactor removing prior_yaw/pitch parameters
717
landmark_points_buffer(complex ? NB_CONTOUR_POINTS_COMPLEX: NB_CONTOUR_POINTS_BASE, 1, CV_32FC2),
818
rv({ 0, 0, 0 }),
919
tv({ 0, 0, 0 })
1020
{
1121
this->prior_pitch = -1.57;
1222
this->prior_yaw = -1.57;
13-
this->prior_distance = prior_distance * -1.;
23+
this->prior_distance = prior_distance * -2.;
1424

1525
this->rv[0] = this->prior_pitch;
1626
this->rv[1] = this->prior_yaw;
1727
this->rv[2] = -1.57;
1828
this->tv[2] = this->prior_distance;
1929

30+
head3dScale = (cv::Mat_<double>(3, 3) <<
31+
x_scale, 0.0, 0,
32+
0.0, y_scale, 0,
33+
0.0, 0.0, z_scale
34+
);
35+
2036
this->complex = complex;
2137

2238
if (!complex)
@@ -110,6 +126,8 @@ PositionSolver::PositionSolver(int width, int height,
110126

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

129+
mat3dcontour = mat3dcontour * head3dScale;
130+
113131
if(complex) std::cout << "Using complex solver" << std::endl;
114132
}
115133

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

170+
// We dont want the Z axis oversaturated.
171+
face_data->translation[2] /= 100;
172+
152173
std::cout << face_data->to_string() << std::endl;
153174

154175
correct_rotation(*face_data);

AITracker/src/PositionSolver.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ class PositionSolver
2222
float prior_yaw = -2.f,
2323
float prior_distance = -1.f,
2424
bool complex = false,
25-
float fov = 56.0f );
25+
float fov = 56.0f,
26+
float x_scale = 1.0f,
27+
float y_scal = 1.0f,
28+
float z_scale = 1.0f);
2629

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

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

0 commit comments

Comments
 (0)