FeatureMatchingAccuracy.vue 29 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 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726
<template>
    <div class="containter">
        <el-row class="contentBox" v-loading="isLoading">
            <el-col :span="7" class="box boxLeft">
                <a-form :model="queryForm" layout="inline" :label-col="{ style: { width: '70px' } }">
                    <a-form-item label="集团:">
                        <a-select v-model:value="queryForm.account_id" style="width: 150px" :options="accountList" @change="onAccountChange" optionFilterProp="label" show-search>
                        </a-select>
                    </a-form-item>
                    <a-form-item label="广场:">
                        <a-select v-model:value="queryForm.plaza_id" style="width: 150px" :options="plazaList" @change="onMallChange" optionFilterProp="label" show-search>
                        </a-select>
                    </a-form-item>
                </a-form>
                <div class="btns">
                    <a-button type="primary" @click="confirmSearch" class="btn">搜索</a-button>
                    <a-button type="primary" @click="addPersonFun" class="btn">新增注册人员</a-button>
                    <!-- <a-button type="primary" @click="confirmSearch" class="btn">预览报告</a-button> -->
                </div>
                <el-table :data="resultList" @row-click='clickRow' :highlight-current-row='true' :rowKey="id" :height="contentHeight" style="width: 100%">
                    <el-table-column type="index" align="center" label="序号" width="80">
                        <template #default="scope">
                            <span v-text="getIndex(scope.$index)"> </span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="name" align="center" label="姓名">
                    </el-table-column>
                    <el-table-column prop="regCount" align="center" label="注册图片数量">
                    </el-table-column>
                    <el-table-column prop="hitCount" align="center" label="命中目标数量">
                    </el-table-column>
                    <el-table-column prop="content" align="center" label="操作" width="150">
                        <template #default="scope">
                          <el-button
                          @click.stop
                            @click="editRow(scope.row)"
                            type="text"
                            size="small"
                            class="tab-btn"
                          >编辑</el-button>
                          <el-button
                          @click.stop
                            @click="deleteRow(scope.row)"
                            type="text"
                            size="small"
                            class="tab-btn"
                          >删除</el-button>
                          <el-button
                            @click.stop
                            @click="hitDetail(scope.row)"
                            type="text"
                            size="small"
                            class="tab-btn"
                          >命中详情</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <a-pagination
                    v-model:current="pageNum"
                    v-model:pageSize="pageSize"
                    :total="total"
                    :show-total="total => `共 ${total} 条`"
                    :pageSizeOptions="['10', '20', '50']"
                    @change="onPageNumChange"
                    @showSizeChange="onPageSizeChange"
                    show-size-changer
                    show-quick-jumper
                    style="text-align:center"
                />
            </el-col>
            <el-col :span="17" class="box boxRight">
                <div style="margin-bottom: 10px;min-height:350px">
                    <a-tabs type="card" v-model:activeKey="activeKey">
                        <a-tab-pane key="1" tab="注册样本" class="regBox">
                            <div>注册样本图:{{regPictureList.length}}</div>
                            <el-row :gutter="10">
                                <el-col :span="3" v-for="item in regPictureList">
                                    <div style="cursor: pointer;" class='hitBox' @click="clickPicture(item)" :class="currentId==item.id?'active':''">
                                        <el-image :src="item.picture_url"
                                                  :fit="'fill'"
                                                  class="single-image">
                                        </el-image>
                                        <span class="el-icon-delete  delHitPic" @click.stop @click="delSamplePic(item)"></span>
                                    </div>
                                </el-col>
                            </el-row>
                        </a-tab-pane>
                        <a-tab-pane key="2" tab="命中目标" class="regBox">
                            <p>命中目标图:{{hitPictureList.length}}</p>
                            <el-row :gutter="10">
                                <el-col :span="3" v-for="item in hitPictureList">
                                    <div style="cursor: pointer;" class='hitBox' @click="clickPicture(item)" :class="currentId==item.id?'active':''">
                                        <el-image :src="item.picture_url"
                                                  :fit="'fill'"
                                                  class="single-image">
                                        </el-image>
                                        <span class="el-icon-delete  delHitPic" @click.stop @click="delHitPic(item)"></span>
                                    </div>
                                </el-col>
                            </el-row>
                        </a-tab-pane>
                    </a-tabs>
                </div>
                <a-form :model="hitSearchObj" layout="inline"  :label-col="{ style: { width: 'auto' } }">
                    <a-form-item label="监控点:" class="secondCondition">
                        <a-select v-model:value="hitSearchObj.gate_id"
                                  style="width: 250px"
                                  mode="multiple"
                                  :maxTagCount="1"
                                  :options="gateList"
                                  optionFilterProp="label"
                                  show-search
                        >
                        </a-select>
                    </a-form-item>
                    <a-form-item label="方向:" class="secondCondition">
                        <a-select v-model:value="hitSearchObj.direction"
                                  mode="multiple"
                                  :maxTagCount="1"
                                  style="width: 125px">
                            <a-select-option :value="1"></a-select-option>
                            <a-select-option :value="-1"></a-select-option>
                        </a-select>
                    </a-form-item>
                    <a-form-item label="分数:" class="secondCondition">
                        <a-input v-model:value="hitSearchObj.score" style="width: 50px;"></a-input>
                    </a-form-item>
                    <a-form-item label="选择日期:" class="secondCondition">
                        <a-date-picker v-model:value="hitSearchObj.date" :format="'YYYY-MM-DD'" style="width: 110px"/>
                    </a-form-item>
                    <a-form-item label="选择时间:" class="secondCondition">
                        <a-time-picker v-model:value="hitSearchObj.startTime" style="width: 90px"/>
                        <a-time-picker v-model:value="hitSearchObj.endTime" style="width: 90px"/>
                    </a-form-item>
                    <a-form-item class="secondCondition">
                        <a-button type="primary" style="margin-right: 5px;" @click="searchPicture">查询</a-button>
                        <a-button type="primary" @click="checkPicture">选中</a-button>
                    </a-form-item>
                </a-form>
                <div class="identifyResult">
                    <div>识别结果:{{identifyResultList.length}}</div>
                    <el-row :gutter="10" class="identifyResultTable" :style="{height:contentHeight-340+'px'}">
                        <el-col :span="3" v-for="item in identifyResultList">
                            <div class="pictureBox">
                                <el-image :src="item.picture_url"
                                          :fit="'fill'"
                                          class="single-image">
                                </el-image>
                                <el-checkbox class="checkBox" v-model="item.checked"></el-checkbox>
                                <span class="score">{{item.featureNum}}</span>
                                <span class="text" @click="clickPicture(item)">
                                    <span class="el-icon-picture-outline iconPic"></span>
                                </span>
                            </div>
                        </el-col>
                    </el-row>
                    <a-pagination
                        v-model:current="pageNum_identify"
                        v-model:pageSize="pageSize_identify"
                        :total="total_identify"
                        :show-total="total => `共 ${total_identify} 条`"
                        :pageSizeOptions="['16', '32', '64']"
                        @change="onPageNumChange_identify"
                        @showSizeChange="onPageSizeChange_identify"
                        show-size-changer
                        show-quick-jumper
                        style="text-align:center"
                    />
                </div>
            </el-col>
        </el-row>
        <addPersonConfig ref="addPersonConfigRef" @refreshParentTable = 'confirmSearch'></addPersonConfig>
        <editPersonConfig ref="editPersonConfigRef" @refreshParentTable = 'confirmSearch'></editPersonConfig>
        <hitDetailDialog ref="hitDetailDialogRef" @refreshParentTable = 'confirmSearch'></hitDetailDialog>
    </div>

</template>

<script>
    import {
        reactive,
        ref,
        toRaw
    } from 'vue'
    import moment from 'moment'
    import snapshotRecordApi from '@/views/SnapshotCluster/SnapshotRecord/SnapshotRecordApi'
    import {
        isArray
    } from '@/PublicUtil/Judgment'
    import {
        filterEmptyValueInObject,
        formatDate,
        formatTime
    } from '@/PublicUtil/PublicUtil'
    import FeatureMatchingAccuracyApi from '@/views/FeatureMatchingAccuracy/FeatureMatchingAccuracyApi'
    import {
        PlusOutlined
    } from '@ant-design/icons-vue'
    import addPersonConfig from './addPerson.vue'
    import editPersonConfig from './editPerson.vue'
    import hitDetailDialog from './hitDetailDialog.vue'
    import {ElMessage,ElMessageBox} from 'element-plus'
    export default {
        components:{
        	addPersonConfig,
            editPersonConfig,
            hitDetailDialog
        },
        setup() {
            const accountList = ref([])
            const plazaList = ref([])
            const queryForm = reactive({
                account_id: '',
                plaza_id: '',
            })
            const hitSearchObj = reactive({
                gate_id: [],
                score:75,
                direction: [1, -1],
                date: moment(moment().format('YYYY-MM-DD'), 'YYYY-MM-DD'),
                startTime: moment('00:00:00', 'HH:mm:ss'),
                endTime: moment('23:59:59', 'HH:mm:ss'),
            })
            const onAccountChange = function() {
                getPlazaList()
            }
            const getPlazaList = function() {
                queryForm.plaza_id = ''
                plazaList.value = []
                snapshotRecordApi.getPlazaList({
                    account_id: queryForm.account_id
                }).then(
                    (r) => {
                        if (isArray(r)) {
                            for (const item of r) {
                                plazaList.value.push({
                                    value: item.id,
                                    label: item.name,
                                })
                            }
                            queryForm.plaza_id = r[0].id
                            getGateList()
                            confirmSearch()
                        }
                    }
                )
            }

            const getAccountList = function() {
                queryForm.account_id = ''
                accountList.value = []
                snapshotRecordApi.getAccountList().then(
                    (r) => {
                        if (isArray(r)) {
                            for (const item of r) {
                                accountList.value.push({
                                    value: item.id,
                                    label: item.name,
                                })
                            }
                            queryForm.account_id = r[0].id
                            getPlazaList()
                        }
                    }
                )
            }
            const onMallChange = function(){
                getGateList()
            }
            const gateList = ref([])
            const getGateList = function() {
                hitSearchObj.gate_id = []
                gateList.value = []
                snapshotRecordApi.getGateList(
                    {
                        account_id: queryForm.account_id,
                        plaza_id: queryForm.plaza_id,
                        type: 0,
                    }
                ).then(
                    (r) => {
                        if (isArray(r.data))
                        {
                            for (const item of r.data)
                            {
                                gateList.value.push(
                                    {
                                        value: item.id,
                                        label: item.name,
                                    }
                                )
                            }
                        }
                    }
                )
            }
            const resultList = ref([])
            const confirmSearch = function() {
                pageNum.value = 1;
                getTableData()
            }
            const getTableData = function(){
                resultList.value = []
                const data = filterEmptyValueInObject(
                    {
                        pageNum:pageNum.value - 1,
                        pageSize:pageSize.value,
                        accountId: queryForm.account_id,
                        mallId: queryForm.plaza_id
                    }
                )
                FeatureMatchingAccuracyApi.getMatch(data).then(
                    (r) => {
                        if(r.msg_code==200){
                            resultList.value = r.data.records;
                            total.value = r.data.total;
                        }
                    }
                )
            }
            
            const onPageNumChange = function(num) {
                pageNum.value = num
                confirmSearch()
            }
            
            const onPageSizeChange = function(current, size) {
                pageNum.value = 1
                pageSize.value = size
                confirmSearch()
            }
            const isLoading = ref(false)
            const pageNum = ref(1)
            const pageSize = ref(10)
            const total = ref()
            const contentHeight = ref(0)
            const addPersonConfigRef = ref();
            const addPersonFun = function(){
                addPersonConfigRef.value.initDialog({
                    account_id:queryForm.account_id,
                    plaza_id:queryForm.plaza_id,
                });
            }
            const editPersonConfigRef = ref();
            const editRow = function(row){
                FeatureMatchingAccuracyApi.getMatchOne(row).then(
                    (r) => {
                        if(r.msg_code==200){
                            editPersonConfigRef.value.initDialog(r.data);
                        }else{
                            ElMessage({
                            	message: r.msg_info,
                            	type: 'error'
                            })
                            return false;
                        }
                    }
                )
            }
            const deleteRow = function(row){
                ElMessageBox.confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                }).then(() => {
                    isLoading.value = true;
                    FeatureMatchingAccuracyApi.delMatch(row).then(
                        (r) => {
                            isLoading.value = false;
                            if(r.msg_code==200){
                                ElMessage({
                                    message: r.msg_info,
                                    type: 'success'
                                })
                                confirmSearch()
                            }else{
                                ElMessage({
                                    message: r.msg_info,
                                    type: 'error'
                                })
                                return false;
                            }
                        }
                    )
                })
            }
            const hitDetailDialogRef = ref()
            const hitDetail = function(row){
                const data = filterEmptyValueInObject(
                    {
                        accountId: row.accountId,
                        mallId: row.mallId,
                        id:row.id
                    }
                )
                FeatureMatchingAccuracyApi.getMatchHitDetail(data).then(
                    (r) => {
                        if(r.msg_code==200){
                            let checkPersonId = ''
                            r.data.forEach(item=>{
                                if(item.personId == row.personUnid){
                                    checkPersonId = item.personId;
                                }
                                item.expand = false;
                                item.records.forEach(record=>{
                                    record.picture_url = window._baseImgUrl +'picture/' +record.bodyPath+record.bodyPic
                                })
                            })
                            hitDetailDialogRef.value.initDialog({
                                regId:row.id,
                                data:r.data,
                                checkPersonId:checkPersonId
                            })
                        }
                    }
                )
            }
            // 注册样本图
            const regPictureList = ref([])
            const hitPictureList = ref([])
            const regPersonId = ref()
            const redPersonObj = ref({})
            const clickRow = function(row){
                isLoading.value = true;
                redPersonObj.value = row;
                regPersonId.value = row.id;
                regPictureList.value = []
                hitPictureList.value = []
                FeatureMatchingAccuracyApi.getMatchOne(row).then(
                    (r) => {
                        isLoading.value = false;
                        if(r.msg_code==200){
                            r.data.faceList.forEach(item=>{
                                item.picture_url = window._baseImgUrl +'picture/' +item.bodyPath+item.bodyPic
                            })
                            regPictureList.value = r.data.faceList
                            r.data.hitList.forEach(item=>{
                                item.picture_url = window._baseImgUrl +'picture/' +item.bodyPath+item.bodyPic
                            })
                            hitPictureList.value = r.data.hitList
                        }
                    }
                )
            }
            // 识别结果
            const identifyResultList = ref([])
            const pageNum_identify = ref(1)
            const pageSize_identify = ref(10)
            const total_identify = ref(0)
            const onPageNumChange_identify = function(num) {
                pageNum_identify.value = num
                clickPicture()
            }
            
            const onPageSizeChange_identify = function(current, size) {
                pageNum_identify.value = 1
                pageSize_identify.value = size
                clickPicture()
            }
            const currentId = ref()
            const clickPicture = function(row){
                const rawData = toRaw(hitSearchObj)
                // if(rawData.gate_id.length<1){
                //     ElMessage({
                //     	message: '请选择监控点',
                //     	type: 'warning'
                //     })
                //     return false;
                // }
                currentId.value = row.id
                isLoading.value = true;
                let data = filterEmptyValueInObject({
                    accountId: queryForm.account_id,
                    mallId: queryForm.plaza_id,
                    gateId: rawData.gate_id.toString(),
                    score: rawData.score,
                    direction: rawData.direction.toString(),
                    startTime: formatDate(rawData.date) + ' ' + formatTime(rawData.startTime),
                    endTime: formatDate(rawData.date) + ' ' + formatTime(rawData.endTime),
                    faceId: currentId.value,
                    page: pageNum_identify.value - 1,
                    pageSize: pageSize_identify.value,
                    regId:regPersonId.value
                })
                FeatureMatchingAccuracyApi.getSearchByPic(data).then(
                    (r) => {
                        isLoading.value = false;
                        if(r.msg_code==200){
                            console.log(r.data.records)
                            r.data.records.forEach(item=>{
                                item.checked = false;
                                item.featureNum = item.featureNum.toFixed(2)
                                item.picture_url = window._baseImgUrl +'picture/' +item.picture_path+item.picture_url
                            })
                            identifyResultList.value = r.data.records
                            total_identify.value = r.data.total
                        }
                    }
                )
            }
            const searchPicture = function(){
                if(!currentId.value){
                    ElMessage({
                    	message: '请选择样本图',
                    	type: 'warning'
                    })
                    return false;
                }
                clickPicture({id:currentId.value})
            }
            // 选中命中目标
            const checkPicture = function(){
                let checkList = []
                identifyResultList.value.forEach(item=>{
                    if(item.checked==true){
                        checkList.push(item.id)
                    }
                })
                if(checkList.length<1){
                    ElMessage({
                    	message: '请选择识别结果图片',
                    	type: 'warning'
                    })
                    return false;
                }
                if(!regPersonId.value){
                    ElMessage({
                    	message: '请选择注册人员',
                    	type: 'warning'
                    })
                    return false;
                }
                isLoading.value = true;
                FeatureMatchingAccuracyApi.addMatchHit({
                    id:regPersonId.value,
                    faceIds:checkList
                }).then(
                    (r) => {
                        isLoading.value = false;
                        if(r.msg_code==200){
                            ElMessage({
                            	message: r.msg_info,
                            	type: 'success'
                            })
                            getTableData()
                            clickRow(redPersonObj.value)
                            searchPicture()
                        }
                    }
                )
            }
            // 删除命中目标图片
            const delHitPic = function(row){
                FeatureMatchingAccuracyApi.delMatchHit({
                    regId:regPersonId.value,
                    faceId:row.id
                }).then(
                    (r) => {
                        isLoading.value = false;
                        if(r.msg_code==200){
                            ElMessage({
                            	message: r.msg_info,
                            	type: 'success'
                            })
                            getTableData()
                            clickRow(redPersonObj.value)
                            searchPicture()
                        }
                    }
                )
            }
            // 删除样本图片
            const delSamplePic = function(row){
                FeatureMatchingAccuracyApi.delMatchSample({
                    regId:regPersonId.value,
                    faceId:row.id
                }).then(
                    (r) => {
                        isLoading.value = false;
                        if(r.msg_code==200){
                            ElMessage({
                            	message: r.msg_info,
                            	type: 'success'
                            })
                            getTableData()
                            clickRow(redPersonObj.value)
                        }
                    }
                )
            }
            const getIndex = function(val) {
                return (pageNum.value - 1) * pageSize.value + val + 1
            }
            const __main = function() {
                contentHeight.value = window.innerHeight - 200
                getAccountList()
            }
            __main()
            return {
                // sequence
                isLoading,
                pageNum,
                pageSize,
                total,
                contentHeight,
                accountList,
                plazaList,
                resultList,
                addPersonConfigRef,
                editPersonConfigRef,
                hitSearchObj,
                gateList,
                activeKey: ref('1'),
                regPictureList,
                pageNum_identify,
                pageSize_identify,
                total_identify,
                identifyResultList,
                currentId,
                hitPictureList,
                hitDetailDialogRef,
                // mapping
                queryForm,
                onAccountChange,
                confirmSearch,
                onPageNumChange,
                onPageSizeChange,
                addPersonFun,
                getIndex,
                editRow,
                deleteRow,
                onMallChange,
                clickRow,
                searchPicture,
                clickPicture,
                onPageNumChange_identify,
                onPageSizeChange_identify,
                checkPicture,
                delHitPic,
                hitDetail,
                delSamplePic
            }
        }
    }
</script>

<style lang="less" scoped>
    .active{
        border : 2px solid #40a9ff
    }
    .regBox{
        height: 300px;
        overflow-y: auto;
        overflow-x: hidden;
    }
    .hitBox{
        position: relative;
    }
    .delHitPic{
        position: absolute;
        right: 0;
        top: 0;
        color: #1890ff;
        font-size: 28px;
    }
    .secondCondition{
        margin-right: 5px !important;
    }
    .identifyResultTable{
        overflow-y: auto;
    }
    .pictureBox{
        position: relative;
        cursor: pointer;
    }
    .checkBox{
        position: absolute;
        left: 1px;
        top: 0;
    }
    .score{
        position: absolute;
        left: 50px;
        top: 0;
        color: red;
        font-weight: 900;
    }
    .iconPic{
        position: absolute;
        right: 0px;
        top: 0px;
        color: #1890ff;
        font-size: 28px;
    }
    
    .single-image{
        width: 100%;
        height: 200px;
    }
    .containter {
        height: 100%;
    }

    .contentBox {
        height: 100%;
    }

    .box {
        height: 100%;
    }

    .boxRight {
        border-left: 5px solid #ccc;
        padding-left: 5px;
    }

    .btns {
        text-align: right;
        margin-top: 10px;
        margin-right: 15px;
    }

    .btn {
        margin-left: 10px;
    }
</style>