Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FaceDetection
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
FaceDetection
Commits
657616e5
Commit
657616e5
authored
Mar 15, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
广告推送
parent
d7f9856a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
22 deletions
+54
-22
FaceDetection/CommonStruct.h
+1
-0
FaceDetection/FaceDetection.cpp
+40
-15
FaceDetection/FaceDetection.vcxproj
+3
-2
FaceDetection/utility/SQLiteModule.cpp
+8
-5
FaceDetection/utility/SQLiteModule.h
+2
-0
Release/fmdata.db
+0
-0
No files found.
FaceDetection/CommonStruct.h
View file @
657616e5
...
@@ -6,6 +6,7 @@ struct TargetInfo
...
@@ -6,6 +6,7 @@ struct TargetInfo
std
::
string
strName
;
//目标名称
std
::
string
strName
;
//目标名称
std
::
string
strPhone
;
//手机号
std
::
string
strPhone
;
//手机号
std
::
string
strConfidence
;
//相似度
std
::
string
strConfidence
;
//相似度
std
::
string
strUserTag
;
//标签
dlib
::
rectangle
rc
;
//头像位置
dlib
::
rectangle
rc
;
//头像位置
int
iCode
=
0
;
//用户编码
int
iCode
=
0
;
//用户编码
bool
bSuccess
=
false
;
//是否成功获取到用户信息
bool
bSuccess
=
false
;
//是否成功获取到用户信息
...
...
FaceDetection/FaceDetection.cpp
View file @
657616e5
...
@@ -54,12 +54,15 @@ using namespace std;
...
@@ -54,12 +54,15 @@ using namespace std;
std
::
string
strUrl
=
"http://139.196.195.9:8788/facesearch/search4File"
;
//接口URL
std
::
string
strUrl
=
"http://139.196.195.9:8788/facesearch/search4File"
;
//接口URL
std
::
string
strAdUrl
=
"http://www.eastjw.com:7000/FamilyInterfaceProject/familyInterface/addFamilyData"
;
//广告URL
std
::
string
strAdUrl
=
"http://www.eastjw.com:7000/FamilyInterfaceProject/familyInterface/addFamilyData"
;
//广告URL
std
::
vector
<
TargetInfo
>
track_dets
;
//跟踪目标所在位置
std
::
vector
<
TargetInfo
>
track_dets
;
//跟踪目标所在位置
CvxText
text
(
"
kait
i.ttf"
);
//字库,否则不支持中文
CvxText
text
(
"
yahe
i.ttf"
);
//字库,否则不支持中文
int64
time_start
=
cv
::
getTickCount
(),
time_end
;
//时间戳,用于计算视频播放帧率
int64
time_start
=
cv
::
getTickCount
(),
time_end
;
//时间戳,用于计算视频播放帧率
int
fps
=
0
;
//帧率
int
fps
=
0
;
//帧率
std
::
vector
<
adStruct
>
vecADInfos
;
//广告信息
std
::
vector
<
adStruct
>
vecADInfos
;
//广告信息
std
::
string
strDeviceId
;
//广告设备id
std
::
string
strDeviceId
;
//广告设备id
#define IN
#define OUT
/****************************************
/****************************************
函数声明
函数声明
****************************************/
****************************************/
...
@@ -84,13 +87,16 @@ void update_img_text(cv::Mat &image, int iframe, int target);
...
@@ -84,13 +87,16 @@ void update_img_text(cv::Mat &image, int iframe, int target);
//获取广告信息,缓存到本地
//获取广告信息,缓存到本地
void
get_adInfo
(
std
::
vector
<
adStruct
>
&
vecInfo
);
void
get_adInfo
(
std
::
vector
<
adStruct
>
&
vecInfo
);
//根据手机号获取用户信息
void
get_userinfo_by_phone
(
IN
const
string
&
phone
,
OUT
adStruct
&
info
);
// 广告播放推送
// 广告播放推送
CURLcode
curl_post_ad
(
const
string
&
url
,
const
string
equipmentId
,
const
string
productId
,
string
&
response
);
CURLcode
curl_post_ad
(
const
string
&
url
,
const
string
equipmentId
,
const
string
productId
,
string
&
response
);
/****************************************
/****************************************
主函数
主函数
****************************************/
****************************************/
int
main
()
int
main
(
int
argc
,
char
**
argv
)
{
{
try
try
{
{
...
@@ -106,10 +112,6 @@ int main()
...
@@ -106,10 +112,6 @@ int main()
// global init curl
// global init curl
curl_global_init
(
CURL_GLOBAL_ALL
);
curl_global_init
(
CURL_GLOBAL_ALL
);
//std::string postAdResponseStr;
//curl_post_ad(strAdUrl,"6739c9fa37f547ef916d06d33a73331a","80052478", postAdResponseStr);
//LOG(INFO) <<"广告推送返回:" <<postAdResponseStr.data();
cv
::
VideoCapture
cap
(
0
);
cv
::
VideoCapture
cap
(
0
);
if
(
!
cap
.
isOpened
())
if
(
!
cap
.
isOpened
())
{
{
...
@@ -152,13 +154,14 @@ int main()
...
@@ -152,13 +154,14 @@ int main()
frame_count
++
;
frame_count
++
;
// Grab a frame
// Grab a frame
cv
::
Mat
origin
,
temp
;
cv
::
Mat
origin
,
temp
;
//if (!cap.read(origin))
// break;
//cv::resize(origin, temp, cv::Size(origin.cols * 1.15, origin.rows * 1.15), 0, 0, cv::INTER_LINEAR); //图片缩放
if
(
!
cap
.
read
(
temp
))
if
(
!
cap
.
read
(
temp
))
{
break
;
break
;
}
//cv::resize(origin, temp, cv::Size(origin.cols * 1.5, origin.rows * 1.5), 0, 0, cv::INTER_LINEAR); //图片缩放
dlib
::
cv_image
<
dlib
::
bgr_pixel
>
cimg
(
temp
);
dlib
::
cv_image
<
dlib
::
bgr_pixel
>
cimg
(
temp
);
//每18帧更新一次
//每18帧更新一次
if
(
frame_count
%
30
==
0
)
{
if
(
frame_count
%
30
==
0
)
{
//faces = detector(cimg);
//faces = detector(cimg);
...
@@ -176,6 +179,7 @@ int main()
...
@@ -176,6 +179,7 @@ int main()
track_dets
[
i
].
bSuccess
=
false
;
track_dets
[
i
].
bSuccess
=
false
;
track_dets
[
i
].
strName
=
""
;
track_dets
[
i
].
strName
=
""
;
track_dets
[
i
].
strPhone
=
""
;
track_dets
[
i
].
strPhone
=
""
;
track_dets
[
i
].
strUserTag
=
""
;
track_dets
[
i
].
iCode
=
0
;
track_dets
[
i
].
iCode
=
0
;
}
}
bTargetUpdate
=
true
;
bTargetUpdate
=
true
;
...
@@ -228,7 +232,7 @@ int main()
...
@@ -228,7 +232,7 @@ int main()
// Display it all on the screen
// Display it all on the screen
win
.
clear_overlay
();
win
.
clear_overlay
();
win
.
set_image
(
cimg
);
win
.
set_image
(
cimg
);
win
.
add_overlay
(
_get_rc_detectors
(
track_dets
),
dlib
::
rgb_pixel
(
0
,
255
,
0
));
win
.
add_overlay
(
_get_rc_detectors
(
track_dets
),
dlib
::
rgb_pixel
(
65
,
210
,
212
));
//计数超过10000,计数归零
//计数超过10000,计数归零
if
(
frame_count
>
100000
)
if
(
frame_count
>
100000
)
...
@@ -372,9 +376,17 @@ void reqUserInfoByImg(int index, string &imgPath)
...
@@ -372,9 +376,17 @@ void reqUserInfoByImg(int index, string &imgPath)
float
fNum
=
0.00
;
float
fNum
=
0.00
;
fNum
=
atof
(
response
.
vecUser
[
0
].
confidence
.
data
());
fNum
=
atof
(
response
.
vecUser
[
0
].
confidence
.
data
());
if
(
fNum
>
80.000
)
{
if
(
fNum
>
80.000
)
{
adStruct
adInfo
;
get_userinfo_by_phone
(
response
.
vecUser
[
0
].
memberTel
,
adInfo
);
target
.
strName
=
"姓名:"
+
response
.
vecUser
[
0
].
memberName
;
target
.
strName
=
"姓名:"
+
response
.
vecUser
[
0
].
memberName
;
target
.
strPhone
=
"电话:"
+
response
.
vecUser
[
0
].
memberTel
;
target
.
strPhone
=
"电话:"
+
response
.
vecUser
[
0
].
memberTel
;
target
.
strConfidence
=
"相似度:"
+
response
.
vecUser
[
0
].
confidence
;
target
.
strConfidence
=
"相似度:"
+
response
.
vecUser
[
0
].
confidence
;
target
.
strUserTag
=
"标签:"
+
adInfo
.
userTag
;
std
::
string
postAdResponseStr
;
curl_post_ad
(
strAdUrl
,
strDeviceId
,
adInfo
.
goodsId
,
postAdResponseStr
);
//curl_post_ad(strAdUrl,"6739c9fa37f547ef916d06d33a73331a","80052478", postAdResponseStr);
LOG
(
INFO
)
<<
"ad push response:"
<<
postAdResponseStr
.
data
();
}
}
}
}
else
{
else
{
...
@@ -382,6 +394,7 @@ void reqUserInfoByImg(int index, string &imgPath)
...
@@ -382,6 +394,7 @@ void reqUserInfoByImg(int index, string &imgPath)
target
.
strName
=
""
;
target
.
strName
=
""
;
target
.
strPhone
=
""
;
target
.
strPhone
=
""
;
target
.
strConfidence
=
""
;
target
.
strConfidence
=
""
;
target
.
strUserTag
=
""
;
}
}
target
.
bSuccess
=
rlt
;
target
.
bSuccess
=
rlt
;
break
;
break
;
...
@@ -401,15 +414,16 @@ void update_img_text(cv::Mat &image, int iframe, int target)
...
@@ -401,15 +414,16 @@ void update_img_text(cv::Mat &image, int iframe, int target)
}
}
std
::
string
strFps
=
"帧率: "
+
to_string
(
fps
);
std
::
string
strFps
=
"帧率: "
+
to_string
(
fps
);
text
.
putText
(
&
IplImage
(
image
),
strFps
.
data
(),
cv
::
Point
(
10
,
20
),
CV_RGB
(
255
,
0
,
0
));
text
.
putText
(
&
IplImage
(
image
),
strFps
.
data
(),
cv
::
Point
(
10
,
20
),
CV_RGB
(
65
,
210
,
212
));
std
::
string
active_models
=
"活跃目标: "
+
to_string
(
target
);
std
::
string
active_models
=
"活跃目标: "
+
to_string
(
target
);
text
.
putText
(
&
IplImage
(
image
),
active_models
.
data
(),
cv
::
Point
(
10
,
50
),
CV_RGB
(
255
,
0
,
0
));
text
.
putText
(
&
IplImage
(
image
),
active_models
.
data
(),
cv
::
Point
(
10
,
50
),
CV_RGB
(
65
,
210
,
212
));
for
(
int
i
=
0
;
i
<
target
;
i
++
)
{
for
(
int
i
=
0
;
i
<
target
;
i
++
)
{
text
.
putText
(
&
IplImage
(
image
),
track_dets
[
i
].
strName
.
data
(),
cvPoint
(
track_dets
[
i
].
rc
.
right
()
+
5
,
track_dets
[
i
].
rc
.
top
()
+
15
),
CV_RGB
(
255
,
0
,
0
));
text
.
putText
(
&
IplImage
(
image
),
track_dets
[
i
].
strName
.
data
(),
cvPoint
(
track_dets
[
i
].
rc
.
right
()
+
5
,
track_dets
[
i
].
rc
.
top
()
+
15
),
CV_RGB
(
65
,
210
,
212
));
text
.
putText
(
&
IplImage
(
image
),
track_dets
[
i
].
strPhone
.
data
(),
cvPoint
(
track_dets
[
i
].
rc
.
right
()
+
5
,
track_dets
[
i
].
rc
.
top
()
+
45
),
CV_RGB
(
255
,
0
,
0
));
text
.
putText
(
&
IplImage
(
image
),
track_dets
[
i
].
strPhone
.
data
(),
cvPoint
(
track_dets
[
i
].
rc
.
right
()
+
5
,
track_dets
[
i
].
rc
.
top
()
+
45
),
CV_RGB
(
65
,
210
,
212
));
text
.
putText
(
&
IplImage
(
image
),
track_dets
[
i
].
strConfidence
.
data
(),
cvPoint
(
track_dets
[
i
].
rc
.
right
()
+
5
,
track_dets
[
i
].
rc
.
top
()
+
75
),
CV_RGB
(
255
,
0
,
0
));
text
.
putText
(
&
IplImage
(
image
),
track_dets
[
i
].
strConfidence
.
data
(),
cvPoint
(
track_dets
[
i
].
rc
.
right
()
+
5
,
track_dets
[
i
].
rc
.
top
()
+
75
),
CV_RGB
(
65
,
210
,
212
));
text
.
putText
(
&
IplImage
(
image
),
track_dets
[
i
].
strUserTag
.
data
(),
cvPoint
(
track_dets
[
i
].
rc
.
right
()
+
5
,
track_dets
[
i
].
rc
.
top
()
+
105
),
CV_RGB
(
65
,
210
,
212
));
}
}
}
}
...
@@ -464,3 +478,13 @@ CURLcode curl_post_ad(const string &url, const string equipmentId, const string
...
@@ -464,3 +478,13 @@ CURLcode curl_post_ad(const string &url, const string equipmentId, const string
curl_easy_cleanup
(
curl
);
curl_easy_cleanup
(
curl
);
return
res
;
return
res
;
}
}
void
get_userinfo_by_phone
(
IN
const
string
&
phone
,
OUT
adStruct
&
info
)
{
for
(
auto
ad
:
vecADInfos
)
{
if
(
ad
.
phone
.
compare
(
phone
)
==
0
)
{
info
=
ad
;
break
;
}
}
}
\ No newline at end of file
FaceDetection/FaceDetection.vcxproj
View file @
657616e5
...
@@ -28,13 +28,13 @@
...
@@ -28,13 +28,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140
_xp
</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140
_xp
</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
</PropertyGroup>
...
@@ -118,6 +118,7 @@
...
@@ -118,6 +118,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
</ClCompile>
<Link>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Console</SubSystem>
...
...
FaceDetection/utility/SQLiteModule.cpp
View file @
657616e5
...
@@ -52,12 +52,13 @@ bool SQLite::_createTable()
...
@@ -52,12 +52,13 @@ bool SQLite::_createTable()
std
::
string
strTableName
=
"fmAdInfo"
;
std
::
string
strTableName
=
"fmAdInfo"
;
if
(
!
isTableExist
(
pDB
,
strTableName
))
{
if
(
!
isTableExist
(
pDB
,
strTableName
))
{
char
szCreate
[
1024
]
=
{
0
};
char
szCreate
[
1024
]
=
{
0
};
sprintf_s
(
szCreate
,
"create table %s(id int NOT NULL,\
sprintf_s
(
szCreate
,
"create table %s(phone varchar(20) NOT NULL,\
user_name varchar(50),\
user_tag varchar(50),\
user_tag varchar(50),\
goods_id varchar(50),\
goods_id varchar(50),\
goods_name varchar(200),\
goods_name varchar(200),\
logtime TIMESTAMP default (datetime('now', 'localtime')),\
logtime TIMESTAMP default (datetime('now', 'localtime')),\
PRIMARY KEY (
id
))"
,
strTableName
.
c_str
());
PRIMARY KEY (
phone
))"
,
strTableName
.
c_str
());
if
(
!
_execSql
(
szCreate
))
{
if
(
!
_execSql
(
szCreate
))
{
//执行失败,退出
//执行失败,退出
exit
(
0
);
exit
(
0
);
...
@@ -159,9 +160,11 @@ int callbackQuery(void* data, int n_columns, char** column_values, char** column
...
@@ -159,9 +160,11 @@ int callbackQuery(void* data, int n_columns, char** column_values, char** column
try
try
{
{
adStruct
adInfo
;
adStruct
adInfo
;
adInfo
.
userTag
=
UTF8ToASCII
(
column_values
[
1
]);
adInfo
.
phone
=
column_values
[
0
];
adInfo
.
goodsId
=
column_values
[
2
];
adInfo
.
userName
=
UTF8ToASCII
(
column_values
[
1
]);
adInfo
.
goodsName
=
UTF8ToASCII
(
column_values
[
3
]);
adInfo
.
userTag
=
UTF8ToASCII
(
column_values
[
2
]);
adInfo
.
goodsId
=
column_values
[
3
];
adInfo
.
goodsName
=
UTF8ToASCII
(
column_values
[
4
]);
vecTempADInfo
.
push_back
(
adInfo
);
vecTempADInfo
.
push_back
(
adInfo
);
}
}
catch
(
std
::
exception
&
ex
)
catch
(
std
::
exception
&
ex
)
...
...
FaceDetection/utility/SQLiteModule.h
View file @
657616e5
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
//广告信息结构体
//广告信息结构体
struct
adStruct
struct
adStruct
{
{
std
::
string
phone
;
//手机号
std
::
string
userName
;
//用户名
std
::
string
userTag
;
//用户标签
std
::
string
userTag
;
//用户标签
std
::
string
goodsId
;
//商品广告ID
std
::
string
goodsId
;
//商品广告ID
std
::
string
goodsName
;
//商品名称
std
::
string
goodsName
;
//商品名称
...
...
Release/fmdata.db
View file @
657616e5
No preview for this file type
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