Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
OpenFace
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanghui.cui
OpenFace
Commits
a7faf8dc
Commit
a7faf8dc
authored
Jan 02, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
演示程序,新增socket转发
parent
440cb3a8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
262 additions
and
18 deletions
+262
-18
Release/ShowDetail.dll
+0
-0
Release/config.ini
+4
-2
exe/FaceLandmarkVid/FaceLandmarkVid.cpp
+205
-10
exe/FaceLandmarkVid/FaceLandmarkVid.vcxproj
+1
-0
exe/FaceLandmarkVid/ShowDetail.lib
+0
-0
exe/FaceLandmarkVid/jsonAnalysis.cpp
+43
-0
exe/FaceLandmarkVid/jsonAnalysis.h
+3
-0
lib/local/LandmarkDetector/include/LandmarkDetectorModel.h
+3
-3
lib/local/LandmarkDetector/src/LandmarkDetectorModel.cpp
+3
-3
No files found.
Release/ShowDetail.dll
View file @
a7faf8dc
No preview for this file type
Release/config.ini
View file @
a7faf8dc
[SYS]
[SYS]
#serach URL
#serach URL
serachURL
=
http://139.224.206.167:8788/facesearch/search4File
serachURL
=
http://139.224.206.167:8788/facesearch/search4File
\ No newline at end of file
#精确度,该值越小,代表需要识别的面部精确度越高
accuracy
=
0.10
\ No newline at end of file
exe/FaceLandmarkVid/FaceLandmarkVid.cpp
View file @
a7faf8dc
...
@@ -58,21 +58,24 @@
...
@@ -58,21 +58,24 @@
// FaceTrackingVid.cpp : Defines the entry point for the console application for tracking faces in videos.
// FaceTrackingVid.cpp : Defines the entry point for the console application for tracking faces in videos.
// Libraries for landmark detection (includes CLNF and CLM modules)
// Libraries for landmark detection (includes CLNF and CLM modules)
#include "LandmarkCoreIncludes.h"
#include "GazeEstimation.h"
#include "jsonAnalysis.h"
#include "../curl/curl.h"
#include "utility/utilCommonAPI.h"
#include "utility/iniOperation.h"
#ifdef WIN32
#ifdef WIN32
#include <WinSock2.h>
#include <process.h>
#include <process.h>
#include <Windows.h>
#include <Windows.h>
#include "IShowDetail.h"
#include "IShowDetail.h"
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "ShowDetail.lib")
#pragma comment(lib, "ShowDetail.lib")
#endif
#endif
#include "LandmarkCoreIncludes.h"
#include "GazeEstimation.h"
#include "jsonAnalysis.h"
#include "../curl/curl.h"
#include "utility/utilCommonAPI.h"
#include "utility/iniOperation.h"
#include <fstream>
#include <fstream>
#include <sstream>
#include <sstream>
...
@@ -108,6 +111,7 @@ printErrorAndAbort( std::string( "Fatal error: " ) + stream )
...
@@ -108,6 +111,7 @@ printErrorAndAbort( std::string( "Fatal error: " ) + stream )
using
namespace
std
;
using
namespace
std
;
string
postResponseStr
;
string
postResponseStr
;
double
accuracy
=
0.00
;
vector
<
string
>
get_arguments
(
int
argc
,
char
**
argv
)
vector
<
string
>
get_arguments
(
int
argc
,
char
**
argv
)
{
{
...
@@ -148,7 +152,7 @@ bool visualise_tracking(cv::Mat& captured_image, cv::Mat_<float>& depth_image, c
...
@@ -148,7 +152,7 @@ bool visualise_tracking(cv::Mat& captured_image, cv::Mat_<float>& depth_image, c
vis_certainty
=
-
1
;
vis_certainty
=
-
1
;
vis_certainty
=
(
vis_certainty
+
1
)
/
(
visualisation_boundary
+
1
);
vis_certainty
=
(
vis_certainty
+
1
)
/
(
visualisation_boundary
+
1
);
if
(
vis_certainty
<
0.06
&&
takephoto
)
{
if
(
vis_certainty
<
accuracy
&&
takephoto
)
{
INFO_STREAM
(
"+++++++++++++++: "
<<
vis_certainty
);
INFO_STREAM
(
"+++++++++++++++: "
<<
vis_certainty
);
flag
=
true
;
flag
=
true
;
}
}
...
@@ -303,20 +307,203 @@ unsigned __stdcall ThreadFunction(void *pThread)
...
@@ -303,20 +307,203 @@ unsigned __stdcall ThreadFunction(void *pThread)
}
}
#endif
#endif
#define BUFFER_SIZE 1024 //缓冲区大小
//Socket server
DWORD
WINAPI
FunSocketServer
(
LPVOID
lpParamter
)
{
WORD
sockVersion
=
MAKEWORD
(
2
,
2
);
WSADATA
wsaData
;
if
(
WSAStartup
(
sockVersion
,
&
wsaData
)
!=
0
)
{
return
0
;
}
//创建套接字
SOCKET
slisten
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
slisten
==
INVALID_SOCKET
)
{
printf
(
"socket error !"
);
return
0
;
}
//绑定IP和端口
sockaddr_in
sin
;
sin
.
sin_family
=
AF_INET
;
sin
.
sin_port
=
htons
(
8888
);
sin
.
sin_addr
.
S_un
.
S_addr
=
INADDR_ANY
;
bind
(
slisten
,
(
SOCKADDR
*
)
&
sin
,
sizeof
(
sin
));
//开始监听
if
(
listen
(
slisten
,
5
)
==
SOCKET_ERROR
)
{
DWORD
k
=
GetLastError
();
printf
(
"listen error !"
);
return
0
;
}
//循环接收数据
SOCKET
sClient
;
sockaddr_in
remoteAddr
;
int
nAddrlen
=
sizeof
(
remoteAddr
);
char
revData
[
255
];
while
(
true
)
{
printf
(
"等待连接...
\n
"
);
sClient
=
accept
(
slisten
,
(
SOCKADDR
*
)
&
remoteAddr
,
&
nAddrlen
);
if
(
sClient
==
INVALID_SOCKET
)
{
printf
(
"accept error !"
);
continue
;
}
//printf("接受到一个连接:%s \r\n", inet_ntoa(remoteAddr.sin_addr));
//接收数据
int
ret
=
recv
(
sClient
,
revData
,
255
,
0
);
if
(
ret
>
0
)
{
revData
[
ret
]
=
0x00
;
printf
(
revData
);
}
//发送数据
const
char
*
sendData
=
"你好,TCP客户端!
\n
"
;
send
(
sClient
,
sendData
,
strlen
(
sendData
),
0
);
closesocket
(
sClient
);
}
closesocket
(
slisten
);
WSACleanup
();
//SOCKET sockTakewayServer;
//SOCKET sockTakewayClient;
//SOCKADDR_IN addrServer;
//SOCKADDR_IN addrClient;
//sockTakewayServer = socket(AF_INET, SOCK_STREAM, 0);
//addrServer.sin_addr.S_un.S_addr = htonl(INADDR_ANY);//INADDR_ANY表示任何IP
//addrServer.sin_family = AF_INET;
//addrServer.sin_port = htons(24000);//绑定端口
//bind(sockTakewayServer, (SOCKADDR*)&addrServer, sizeof(SOCKADDR));
////Listen监听端
//listen(sockTakewayServer, 5);//5为等待连接数目
//int len = sizeof(SOCKADDR);
//char* takeWayRecvBuf = new char[BUFFER_SIZE * 10]; //外卖数据接收区
//int nErrCode = 0;
//while (true)
//{
// sockTakewayClient = accept(sockTakewayServer, (SOCKADDR*)&addrClient, &len);
// if (sockTakewayClient == SOCKET_ERROR)
// {
// continue;
// }
// //接收并打印客户端数据
// int rlt = recv(sockTakewayClient, takeWayRecvBuf, BUFFER_SIZE * 10, 0);
// if (rlt > 0)
// {
// takeWayRecvBuf[rlt] = '\0';
// const char * sendData = "你好,TCP客户端!\n";
// send(sockTakewayClient, sendData, strlen(sendData), 0);
// }
// closesocket(sockTakewayClient);
//}
//delete[] takeWayRecvBuf;
//closesocket(sockTakewayServer);
return
0
;
}
bool
bTakePic
=
false
;
//是否开始拍照
#include <dlib/sockets.h>
#include <dlib/server.h>
//#pragma comment(lib, "newlib/dlib.lib")
HANDLE
g_hSemaphore
=
NULL
;
string
socketBackJson
;
class
serv
:
public
dlib
::
server
{
void
on_connect
(
dlib
::
connection
&
con
)
{
char
tmpJson
[
1000
];
int
n
=
con
.
read
(
tmpJson
,
1000
);
tmpJson
[
n
]
=
'\0'
;
cout
<<
"recived data:"
<<
tmpJson
<<
endl
;
int
fm_cmd
=
SocketRequestJson
(
tmpJson
);
if
(
2002
==
fm_cmd
)
{
bTakePic
=
true
;
//信号量
g_hSemaphore
=
CreateSemaphore
(
NULL
//信号量的安全特性
,
1
//设置信号量的初始计数。可设置零到最大值之间的一个值
,
1
//设置信号量的最大计数
,
NULL
//指定信号量对象的名称
);
if
(
NULL
==
g_hSemaphore
)
{
cout
<<
"create hSemaphore failed! error_code:"
<<
GetLastError
()
<<
endl
;
return
;
}
WaitForSingleObject
(
g_hSemaphore
,
INFINITE
);
//-----------
con
.
write
(
socketBackJson
.
data
(),
socketBackJson
.
length
());
}
con
.
shutdown
();
}
};
serv
our_server
;
void
dlibServer
()
{
try
{
// set up the server object we have made
our_server
.
set_listening_port
(
24777
);
// Tell the server to begin accepting connections.
our_server
.
set_max_connections
(
10000
);
our_server
.
start_async
();
cout
<<
"Press enter to end this program"
<<
endl
;
//cin.get();
}
catch
(
exception
&
e
)
{
cout
<<
e
.
what
()
<<
endl
;
}
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
dlibServer
();
std
::
string
strFilePath
=
GetProcDir
();
std
::
string
strFilePath
=
GetProcDir
();
std
::
string
strPathImg
=
strFilePath
+
"tmpimg.jpg"
;
std
::
string
strPathImg
=
strFilePath
+
"tmpimg.jpg"
;
std
::
string
strPathIni
=
strFilePath
+
"config.ini"
;
std
::
string
strPathIni
=
strFilePath
+
"config.ini"
;
std
::
string
strUrl
=
ZIni
::
readString
(
"SYS"
,
"serachURL"
,
""
,
strPathIni
.
c_str
());
std
::
string
strUrl
=
ZIni
::
readString
(
"SYS"
,
"serachURL"
,
""
,
strPathIni
.
c_str
());
accuracy
=
ZIni
::
readDouble
(
"SYS"
,
"accuracy"
,
0.06
,
strPathIni
.
c_str
());
////初始化WSA
//WORD sockVersion = MAKEWORD(2, 2);
//WSADATA wsaData;
//if (WSAStartup(sockVersion, &wsaData) != 0)
//{
// return 0;
//}
//启动外卖监控线程
//HANDLE hSocket = CreateThread(NULL, 0, FunSocketServer, NULL, 0, NULL);
//CloseHandle(hSocket);
vector
<
string
>
arguments
=
get_arguments
(
argc
,
argv
);
vector
<
string
>
arguments
=
get_arguments
(
argc
,
argv
);
// Some initial parameters that can be overriden from command line
// Some initial parameters that can be overriden from command line
vector
<
string
>
files
,
depth_directories
,
output_video_files
,
out_dummy
;
vector
<
string
>
files
,
depth_directories
,
output_video_files
,
out_dummy
;
bool
bTakePic
=
false
;
//是否开始拍照
// By default try webcam 0
// By default try webcam 0
int
device
=
0
;
int
device
=
0
;
...
@@ -538,6 +725,14 @@ int main (int argc, char **argv)
...
@@ -538,6 +725,14 @@ int main (int argc, char **argv)
}
}
sServerResponse
response
=
GetServerResultData
(
postResponseStr
.
data
());
sServerResponse
response
=
GetServerResultData
(
postResponseStr
.
data
());
//-------------socket返回给pos----------------
if
(
response
.
vecUser
.
size
()
>
0
)
{
socketBackJson
=
GetSocketResultJson
(
100
,
"success"
,
response
.
vecUser
[
0
].
memberTel
.
data
());
}
ReleaseSemaphore
(
g_hSemaphore
,
1
,
NULL
);
//---------------------------------------------
// global release
// global release
curl_global_cleanup
();
curl_global_cleanup
();
bTakePic
=
false
;
bTakePic
=
false
;
...
@@ -596,7 +791,7 @@ int main (int argc, char **argv)
...
@@ -596,7 +791,7 @@ int main (int argc, char **argv)
{
{
return
(
0
);
return
(
0
);
}
}
else
if
(
character_press
==
'
'
)
//空格键按下,开始拍照
else
if
(
character_press
==
'
s'
)
{
{
bTakePic
=
true
;
bTakePic
=
true
;
}
}
...
...
exe/FaceLandmarkVid/FaceLandmarkVid.vcxproj
View file @
a7faf8dc
...
@@ -116,6 +116,7 @@
...
@@ -116,6 +116,7 @@
<Link>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</Link>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
...
...
exe/FaceLandmarkVid/ShowDetail.lib
View file @
a7faf8dc
No preview for this file type
exe/FaceLandmarkVid/jsonAnalysis.cpp
View file @
a7faf8dc
...
@@ -104,4 +104,46 @@ sServerResponse GetServerResultData(const char* json)
...
@@ -104,4 +104,46 @@ sServerResponse GetServerResultData(const char* json)
}
}
return
res
;
return
res
;
}
int
SocketRequestJson
(
const
char
*
json
)
{
int
result
=
0
;
rapidjson
::
Document
document
;
// 定义一个Document对象
document
.
Parse
(
json
);
// 解析,Parse()无返回值,也不会抛异常
if
(
document
.
HasParseError
())
// 通过HasParseError()来判断解析是否成功
{
// 可通过GetParseError()取得出错代码,
// 注意GetParseError()返回的是一个rapidjson::ParseErrorCode类型的枚举值
// 使用函数rapidjson::GetParseError_En()得到错误码的字符串说明,这里的En为English简写
// 函数GetErrorOffset()返回出错发生的位置
//LOG_ERROR("GetTakeawayPrintInfo JSON parse error: (%d:%d)", document.GetParseError(), document.GetErrorOffset())
//return false;
}
else
{
rapidjson
::
Value
&
fm_cmd
=
document
[
"fm_cmd"
];
result
=
fm_cmd
.
GetInt
();
}
return
result
;
}
std
::
string
GetSocketResultJson
(
const
int
statuscode
,
const
char
*
msg
,
const
char
*
phone
)
{
rapidjson
::
StringBuffer
buffer
;
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
writer
.
Key
(
"statusCode"
);
writer
.
Int
(
statuscode
);
writer
.
Key
(
"msg"
);
writer
.
String
(
msg
);
writer
.
Key
(
"member_id"
);
writer
.
String
(
phone
);
writer
.
EndObject
();
return
buffer
.
GetString
();
}
}
\ No newline at end of file
exe/FaceLandmarkVid/jsonAnalysis.h
View file @
a7faf8dc
...
@@ -20,4 +20,7 @@ std::string GetIdentityUserJson(const char* photo);
...
@@ -20,4 +20,7 @@ std::string GetIdentityUserJson(const char* photo);
sServerResponse
GetServerResultData
(
const
char
*
json
);
sServerResponse
GetServerResultData
(
const
char
*
json
);
int
SocketRequestJson
(
const
char
*
json
);
std
::
string
GetSocketResultJson
(
const
int
statuscode
,
const
char
*
msg
,
const
char
*
phone
);
#endif
#endif
lib/local/LandmarkDetector/include/LandmarkDetectorModel.h
View file @
a7faf8dc
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// all rights reserved.
// all rights reserved.
//
//
// THIS SOFTWARE IS PROVIDED “AS IS
”
FOR ACADEMIC USE ONLY AND ANY EXPRESS
// THIS SOFTWARE IS PROVIDED “AS IS
?
FOR ACADEMIC USE ONLY AND ANY EXPRESS
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
// POSSIBILITY OF SUCH DAMAGE.
// POSSIBILITY OF SUCH DAMAGE.
//
//
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// of the Software may be covered by so-called “open source
”
software licenses (“Open Source
// of the Software may be covered by so-called “open source
?
software licenses (“Open Source
// Components
”)
, which means any software licenses approved as open source licenses by the
// Components
?
, which means any software licenses approved as open source licenses by the
// Open Source Initiative or any substantially similar licenses, including without limitation any
// Open Source Initiative or any substantially similar licenses, including without limitation any
// license that, as a condition of distribution of the software licensed under such license,
// license that, as a condition of distribution of the software licensed under such license,
// requires that the distributor make the software available in source code format. Licensor shall
// requires that the distributor make the software available in source code format. Licensor shall
...
...
lib/local/LandmarkDetector/src/LandmarkDetectorModel.cpp
View file @
a7faf8dc
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// all rights reserved.
// all rights reserved.
//
//
// THIS SOFTWARE IS PROVIDED “AS IS
”
FOR ACADEMIC USE ONLY AND ANY EXPRESS
// THIS SOFTWARE IS PROVIDED “AS IS
?
FOR ACADEMIC USE ONLY AND ANY EXPRESS
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
// POSSIBILITY OF SUCH DAMAGE.
// POSSIBILITY OF SUCH DAMAGE.
//
//
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// of the Software may be covered by so-called “open source
”
software licenses (“Open Source
// of the Software may be covered by so-called “open source
?
software licenses (“Open Source
// Components
”)
, which means any software licenses approved as open source licenses by the
// Components
?
, which means any software licenses approved as open source licenses by the
// Open Source Initiative or any substantially similar licenses, including without limitation any
// Open Source Initiative or any substantially similar licenses, including without limitation any
// license that, as a condition of distribution of the software licensed under such license,
// license that, as a condition of distribution of the software licensed under such license,
// requires that the distributor make the software available in source code format. Licensor shall
// requires that the distributor make the software available in source code format. Licensor shall
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment