Skip to content

Commit d74ccb0

Browse files
authored
Merge pull request #2 from AIRLegend/dev
Merge advances of dev into master
2 parents 08b059b + a6048a9 commit d74ccb0

23 files changed

+651
-146
lines changed

AITracker/src/PositionSolver.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#include "PositionSolver.h"
22

33

4-
PositionSolver::PositionSolver(int width, int height):
4+
PositionSolver::PositionSolver(int width, int height,
5+
float prior_pitch, float prior_yaw, float prior_distance):
56
contour_indices{ 0,1,8,15,16,27,28,29,30,31,32,33,34,35,36,39,42,45 }
67
{
8+
this->prior_pitch = (1.1f * (prior_pitch + 90.f) / 180.f) - (double)2.5f;
9+
this->prior_distance = prior_distance * -2. ;
10+
this->prior_yaw = (1.84f*(prior_yaw + 90.f)/180.f) - (double)3.14f;
11+
12+
std::cout << "PRIORS CALCULATED: \nPITCH: " <<this->prior_pitch << " YAW: " << this->prior_yaw << " DISTANCE: " << this->prior_distance;
13+
714
mat3dcontour = (cv::Mat_<double>(18, 3) <<
815
0.45517698, 0.30089578, -0.76442945,
916
0.44899884, 0.16699584, -0.765143,
@@ -104,13 +111,6 @@ PositionSolver::PositionSolver(int width, int height):
104111
0, 0, 1
105112
);
106113

107-
/*camera_matrix = (cv::Mat_<double>(3, 3) <<
108-
34.32, 0, 307.3,
109-
0, 34.17, 251.4,
110-
0, 0, 1
111-
);*/
112-
113-
114114
camera_distortion = (cv::Mat_<double>(4, 1) << 0, 0, 0, 0);
115115
}
116116

@@ -125,7 +125,7 @@ void PositionSolver::solve_rotation(FaceData* face_data)
125125
);
126126
}
127127

128-
std::vector<double> rv({ -2, -2, 0 }), tv({0,0,-3});
128+
std::vector<double> rv({ prior_pitch, prior_yaw, 0 }), tv({0, 0, prior_distance});
129129
cv::Mat rvec(rv), tvec(tv);
130130

131131
cv::Mat ip(landmarkPoints);
@@ -142,15 +142,11 @@ void PositionSolver::solve_rotation(FaceData* face_data)
142142

143143
//std::cout << rvec << std::endl;
144144

145-
146-
//double rot[9] = { 0 };
147145
cv::Mat rotM(3, 3, CV_64FC1);
148146
cv::Rodrigues(rvec, rotM);
149147

150148

151149
cv::Mat concated(3, 4, CV_64FC1);
152-
//cv::Mat transs(3, 1, CV_64FC1);
153-
//cv::hconcat(rotM, transs, concated);
154150
cv::hconcat(rotM, tvec, concated);
155151

156152

@@ -166,12 +162,12 @@ void PositionSolver::solve_rotation(FaceData* face_data)
166162
);
167163

168164

169-
double d = 6;
165+
//double d = 6;
170166

171167
//Correct relative translation
172-
double yaw_angle = rvec.at<double>(1,0);
173-
double y_trans = tvec.at<double>(1, 0); //Bien
174-
double correction = y_trans <= 0 ? yaw_angle + std::atan(y_trans / d) : yaw_angle - std::atan(y_trans / d);
168+
//double yaw_angle = rvec.at<double>(1,0);
169+
//double y_trans = tvec.at<double>(1, 0); //Bien
170+
//double correction = y_trans <= 0 ? yaw_angle + std::atan(y_trans / d) : yaw_angle - std::atan(y_trans / d);
175171

176172

177173
for (int i = 0; i < 3; i++)

AITracker/src/PositionSolver.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ class PositionSolver
88
{
99

1010
public:
11-
PositionSolver(int im_width, int im_height);
11+
12+
double prior_pitch, prior_yaw, prior_distance;
13+
14+
PositionSolver(
15+
int im_width,
16+
int im_height,
17+
float prior_pitch = -2.f,
18+
float prior_yaw = -2.f,
19+
float prior_distance = -1.2f);
1220

1321
void solve_rotation(FaceData* face_data);
1422

AITracker/src/model.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,29 @@
1212

1313

1414

15-
Tracker::Tracker(int img_width, int img_heigth):
15+
Tracker::Tracker(PositionSolver* solver, std::wstring& detection_model_path, std::wstring& landmark_model_path):
1616
improc()
1717
//buffer_input_tensor(Ort::Value::CreateTensor<float>(*memory_info, buffer_data, tensor_input_size, tensor_input_dims, 4))
1818
{
19-
const wchar_t* modelFile = L"E:\\OpenSeeFace\\models\\mnv3_detection_opt.onnx";
19+
const wchar_t* modelFile = std::wstring(detection_model_path.begin(), detection_model_path.end()).data(); //L"models/mnv3_detection_opt.onnx";
2020
enviro = new Ort::Env(ORT_LOGGING_LEVEL_WARNING, "test");
2121
session_options = new Ort::SessionOptions();
2222
//session_options->SetIntraOpNumThreads(1);
2323
//session_options->SetInterOpNumThreads(1);
2424
omp_set_num_threads(1);
2525

2626
//session_options->SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED);
27-
session = new Ort::Session(*enviro, modelFile, *session_options);
27+
session = new Ort::Session(*enviro, detection_model_path.data(), *session_options);
2828
allocator = new Ort::AllocatorWithDefaultOptions();
2929
memory_info = (Ort::MemoryInfo*)allocator->GetInfo();
3030

3131

32-
const wchar_t* modelFile2 = L"E:\\OpenSeeFace\\models\\mnv3_opt_b.onnx";
33-
session_lm = new Ort::Session(*enviro, modelFile2, *session_options);
32+
33+
const wchar_t* modelFile2 = std::wstring(landmark_model_path.begin(), landmark_model_path.end()).data();//L"models/mnv3_opt_b.onnx";
34+
session_lm = new Ort::Session(*enviro, landmark_model_path.data(), *session_options);
3435

3536
//facedata = new FaceData();
36-
solver = new PositionSolver(img_width, img_heigth);
37+
this->solver = solver;//new PositionSolver(img_width, img_heigth, solver_prior_pitch, solver_prior_yaw, solver_prior_distance);
3738

3839
tensor_input_size = tensor_input_dims[1] * tensor_input_dims[2] * tensor_input_dims[3];
3940

@@ -44,7 +45,11 @@ Tracker::Tracker(int img_width, int img_heigth):
4445

4546

4647
//buffer_input_tensor = &Ort::Value::CreateTensor<float>(*memory_info, buffer_data, tensor_input_size, tensor_input_dims, 4);
48+
49+
}
4750

51+
Tracker::~Tracker()
52+
{
4853
}
4954

5055
void Tracker::predict(cv::Mat& image, FaceData& face_data)

AITracker/src/model.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class Tracker
1818
{
1919

2020
public:
21-
Tracker(int img_width, int img_heigth);
21+
Tracker(PositionSolver* solver, std::wstring& detection_model_path, std::wstring& landmark_model_path);
22+
~Tracker();
2223
void predict(cv::Mat& image, FaceData& face_data);
2324

2425
private:

Client/Client.rc

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Microsoft Visual C++ generated resource script.
2+
//
3+
#pragma code_page(65001)
4+
5+
#include "resource.h"
6+
7+
#define APSTUDIO_READONLY_SYMBOLS
8+
/////////////////////////////////////////////////////////////////////////////
9+
//
10+
// Generated from the TEXTINCLUDE 2 resource.
11+
//
12+
#include "winres.h"
13+
14+
/////////////////////////////////////////////////////////////////////////////
15+
#undef APSTUDIO_READONLY_SYMBOLS
16+
17+
/////////////////////////////////////////////////////////////////////////////
18+
// English (United States) resources
19+
20+
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
21+
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
22+
23+
/////////////////////////////////////////////////////////////////////////////
24+
//
25+
// PNG
26+
//
27+
28+
IDB_PNG1 PNG "res\\logo.png"
29+
30+
31+
/////////////////////////////////////////////////////////////////////////////
32+
//
33+
// Icon
34+
//
35+
36+
// Icon with lowest ID value placed first to ensure application icon
37+
// remains consistent on all systems.
38+
IDI_ICON1 ICON "res\\logo_256px.ico"
39+
40+
#endif // English (United States) resources
41+
/////////////////////////////////////////////////////////////////////////////
42+
43+
44+
/////////////////////////////////////////////////////////////////////////////
45+
// Spanish (Spain, International Sort) resources
46+
47+
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN)
48+
LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN
49+
50+
#ifdef APSTUDIO_INVOKED
51+
/////////////////////////////////////////////////////////////////////////////
52+
//
53+
// TEXTINCLUDE
54+
//
55+
56+
1 TEXTINCLUDE
57+
BEGIN
58+
"resource.h\0"
59+
END
60+
61+
2 TEXTINCLUDE
62+
BEGIN
63+
"#include ""winres.h""\r\n"
64+
"\0"
65+
END
66+
67+
3 TEXTINCLUDE
68+
BEGIN
69+
"\r\n"
70+
"\0"
71+
END
72+
73+
#endif // APSTUDIO_INVOKED
74+
75+
#endif // Spanish (Spain, International Sort) resources
76+
/////////////////////////////////////////////////////////////////////////////
77+
78+
79+
80+
#ifndef APSTUDIO_INVOKED
81+
/////////////////////////////////////////////////////////////////////////////
82+
//
83+
// Generated from the TEXTINCLUDE 3 resource.
84+
//
85+
86+
87+
/////////////////////////////////////////////////////////////////////////////
88+
#endif // not APSTUDIO_INVOKED
89+

Client/Client.vcxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
</Link>
153153
</ItemDefinitionGroup>
154154
<ItemGroup>
155+
<ClCompile Include="src\model\Config.cpp" />
155156
<ClCompile Include="src\model\IPResolver.cpp" />
156157
<ClCompile Include="src\camera\Ps3Camera.cpp" />
157158
<ClCompile Include="src\presenter\presenter.cpp" />
@@ -168,6 +169,8 @@
168169
</ItemGroup>
169170
<ItemGroup>
170171
<ClInclude Include="Include\ps3eye.h" />
172+
<ClInclude Include="resource.h" />
173+
<ClInclude Include="src\model\Config.h" />
171174
<ClInclude Include="src\model\IPResolver.h" />
172175
<ClInclude Include="src\camera\Ps3Camera.h" />
173176
<ClInclude Include="src\camera\ICamera.h" />
@@ -184,6 +187,13 @@
184187
<Project>{212672b2-4d87-4ded-9345-d66fb4cbf4ad}</Project>
185188
</ProjectReference>
186189
</ItemGroup>
190+
<ItemGroup>
191+
<ResourceCompile Include="Client.rc" />
192+
</ItemGroup>
193+
<ItemGroup>
194+
<Image Include="res\logo.png" />
195+
<Image Include="res\logo_256px.ico" />
196+
</ItemGroup>
187197
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
188198
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
189199
<Import Project="$(QtMsBuild)\qt.targets" />

Client/Client.vcxproj.filters

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<ClCompile Include="src\model\IPResolver.cpp" />
5+
<ClCompile Include="src\camera\Ps3Camera.cpp" />
6+
<ClCompile Include="src\presenter\presenter.cpp" />
7+
<ClCompile Include="src\Main.cpp" />
8+
<ClCompile Include="src\model\UDPSender.cpp" />
9+
<ClCompile Include="src\view\WindowMain.cpp" />
10+
<ClCompile Include="src\model\Config.cpp">
11+
<Filter>Source Files</Filter>
12+
</ClCompile>
13+
</ItemGroup>
14+
<ItemGroup>
15+
<ClInclude Include="Include\ps3eye.h" />
16+
<ClInclude Include="src\model\IPResolver.h" />
17+
<ClInclude Include="src\camera\Ps3Camera.h" />
18+
<ClInclude Include="src\camera\ICamera.h" />
19+
<ClInclude Include="src\presenter\i_presenter.h" />
20+
<ClInclude Include="src\presenter\presenter.h" />
21+
<ClInclude Include="src\model\UDPSender.h" />
22+
<ClInclude Include="src\view\i_view.h" />
23+
<ClInclude Include="src\model\Config.h">
24+
<Filter>Header Files</Filter>
25+
</ClInclude>
26+
<ClInclude Include="resource.h">
27+
<Filter>Header Files</Filter>
28+
</ClInclude>
29+
</ItemGroup>
30+
<ItemGroup>
31+
<QtMoc Include="src\view\WindowMain.h" />
32+
</ItemGroup>
33+
<ItemGroup>
34+
<QtRcc Include="src\view\qml.qrc" />
35+
</ItemGroup>
36+
<ItemGroup>
37+
<QtUic Include="src\view\MainWindow.ui" />
38+
</ItemGroup>
39+
<ItemGroup>
40+
<Filter Include="Source Files">
41+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
42+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
43+
<ParseFiles>true</ParseFiles>
44+
</Filter>
45+
<Filter Include="Header Files">
46+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
47+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
48+
<ParseFiles>true</ParseFiles>
49+
</Filter>
50+
</ItemGroup>
51+
<ItemGroup>
52+
<ResourceCompile Include="Client.rc" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<Image Include="res\logo.png" />
56+
<Image Include="res\logo_256px.ico" />
57+
</ItemGroup>
58+
</Project>

Client/prefs.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[General]
2+
ip=
3+
port=4242
4+
prior_pitch=0
5+
prior_yaw=0
6+
prior_distance=0.6

Client/res/logo.png

60.9 KB
Loading

Client/res/logo_256px.ico

31.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)