onePic.vue
4 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!--单人脸搜索-->
<template>
<div >
<div >
<el-upload
class="avatar-uploader"
action=""
:http-request="uploadsearchimg"
:show-file-list="false"
:on-success="handleAvatarSuccess"
>
<img v-if="imageUrl" :src="imageUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<div class="pic-search-box">
<el-select v-model="dbname" placeholder="选择比对库">
<el-option v-for="item in crucialData" :key="item.code" :label="item.name" :value="item.code"></el-option>
</el-select>
</div>
<div class="sim-box">
<span class="demonstration">相似度:</span>
<div class="similarity">
<el-slider v-model="similarity" ></el-slider>
</div>
</div>
<div class="pic-search-box">
</div>
<div class="">
<el-button class="search-btn" @click="searchPic()">查询</el-button>
</div>
</div>
</div>
</template>
<script>
import {mapGetters} from 'vuex'
export default {
data() {
return {
address: "",
camera: "",
value: "",
value1: "",
imageUrl:'',
dbname:'',
similarity:50,
crucialData:[]
};
},
methods: {
handleAvatarSuccess(res, file) {
this.imageUrl = URL.createObjectURL(file.raw);
},
beforeAvatarUpload(file){
const isJPG = file.type === "image/jpeg";
const isLt1M = file.size / 1024 / 1024 < 1;
if (!isJPG) {
this.$message.error("上传头像图片只能是 JPG 格式!");
}
if (!isLt1M) {
this.$message.error("上传头像图片大小不能超过 1MB!");
}
return isJPG && isLt1M;
},
uploadsearchimg(file){
var file = file;
this.base64Img(file).then(res => {
this.imageUrl = res.src
this.base64 = res.pic_base64
})
},
initDbData(){
this.faceapi.getFaceDbData().then(res => {
this.crucialData = res.list_data;
})
},
searchPic(){
let data = {
sessionId: localStorage.getItem("user_id"),
similarity:this.similarity,
crucial_type:this.dbname,
limit:20,
pics_base64:[this.base64]
}
console.log(data);
this.axios.post(this.API.faceweb + '/faces/image_search', data).then((res)=> {
});
}
},
computed:{
...mapGetters(['faceinfo','alarmInfo'])
},
created() {
this.initDbData()
},
watch:{
alarmInfo(val){
if(val.params.msg_type === 'face_img_search'){
if(sessionStorage.getItem('activename')=='one'){
console.log('one')
setTimeout(()=>{
this.axios.get(val.params.msg_url).then(res => {
this.$emit('onceFace',res.data)
})
},300)
}
}
}
}
};
</script>
<style lang="stylus" scoped>
.pic-box{
background: #fff;
display flex
height calc(100vh - 110px)
.pic-left-box{
width 230px
box-shadow 3px 0px 3px rgba(0,0,0,.4)
}
}
.search-btn{
margin 50px
}
.pic-search-box{
width 90%
margin 10px auto 0
color #333
}
.sim-box{
margin-top 15px
.demonstration,.similarity{
float left
}
.demonstration{
color #999
line-height 35px
padding-left 10px
font-size 14px;
}
.similarity{
width 160px
margin-left 6px
}
}
.avatar-uploader ,.el-upload {
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
.avatar-uploader-icon {
margin 0 10px
border: 1px dashed #d9d9d9;
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
.avatar-uploader{
margin 0 auto
width: 200px;
height: 200px;
.avatar{
height 100%
width 100%
}
}
.avatar {
width: 200px;
height: 200px;
display: block;
}
</style>