face_search.ftl
3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<div class="layui-row">
<div class="layui-col-xs7 layui-col-md-offset3">
<div style="width: 1000px;height: 800px;border: 1px;background-color: #383939">
<div style="float:left;height: 80px;width: 100%;line-height: 80px;text-align: center;color: #ffffff;font-size: 40px">
请选择识别的人脸的照片
</div>
<#--<div style="float:right;height: 80px;width: 49%;line-height: 80px;text-align: center;color: #E51C23;font-size: 40px">-->
<#--相似度:60%-->
<#--</div>-->
<a href="#">
<div id="imageDivComp" style="background-image :url(images/v2_pgfcmk.png) ; background-repeat: no-repeat;background-position: center center;background-size: cover; /* 覆盖:图片成比例填满盒子。可用于适配 */
background-size: contain; float:left;height: 500px;width: 100%;border: 1px solid #877dd6">
</div>
<#--</a>-->
<#--<div style="background-image :url(images/v2_pgfcnq.jpg); background-repeat: no-repeat;background-position: center center;float:right;height: 500px;width: 49%;border: 2px solid #877dd6">-->
<#--</div>-->
<input type="file" name="file" id="chooseFileComp" onchange="chooseFileChangeComp()" style="display:none;"/>
<div style="float:left;height: 40px;width: 100%;line-height: 40px;text-align: center;color: #ffffff;font-size: 30px">
<div id="nameDiv"></div>
<div id="similarDiv"></div>
<div id="ageDiv"></div>
<div id="genderDiv"></div>
</div>
</div>
</div>
</div>
</div>
<script>
$("#imageDivComp").click(function () {
$("#chooseFileComp").click();
});
function chooseFileChangeComp() {
var file = $("#chooseFileComp")[0].files[0];
if (file == undefined) {
return
}
var img=$("#imageDivComp");
img.css("background-image", 'url(' + URL.createObjectURL(file) + ')');
var formData = new FormData();
formData.append("groupId", "101")
if (file == undefined) {
alert("请先选择有人脸的照片")
return;
}
formData.append("file", file);
$.ajax({
type: "post",
url: "/faceSearch",
data: formData,
contentType: false,
processData: false,
async: false,
success: function (text) {
var res = JSON.stringify(text)
if (text.code == 0) {
var name = text.data.name;
$("#nameDiv").html("姓名:" + name);
var similar = text.data.similarValue;
$("#similarDiv").html("相似度:" + similar + "%");
var age = text.data.age;
$("#ageDiv").html("年龄:" + age);
var gender = text.data.gender;
$("#genderDiv").html("性别:" + gender);
img.css("background-image", 'url(' + text.data.image + ')');
} else {
$("#nameDiv").html("");
$("#similarDiv").html("");
$("#ageDiv").html("");
$("#genderDiv").html("");
alert("人脸不匹配")
}
},
error: function (error) {
$("#nameDiv").html("");
$("#similarDiv").html("");
$("#ageDiv").html("");
$("#genderDiv").html("");
alert(JSON.stringify(error))
}
});
}
</script>