Skip to content

Commit 5d02112

Browse files
committed
CVAuto: 解决点击、光标对应框位置未自适应宽高,解决不能自适应横向位置,解决 .url undeifined
1 parent d08ca4d commit 5d02112

File tree

2 files changed

+58
-23
lines changed
  • APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/cv

2 files changed

+58
-23
lines changed

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/cv/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@
262262
<ul class="historys" style="width: 100%; height: 100%;overflow: hidden;overflow-y: scroll;padding-bottom: 50px">
263263
<li v-for="(item, index) in testCases" :id="'docItem' + index" >
264264
<div style="display: inline-table">
265-
<button class="hint--right" :data-hint="item.Document.url" v-show="isShowMethod()" style="width: 60px; margin-right: 0px;padding: 0px;" id="vDocMethod" @click="restoreRemoteAndTest(index, item)">{{ getMethodName(item.Document.method, item.Document.type) }}</button>
266-
<button class="hint--right" :data-hint="item.Document.request" v-show="isShowType()" style="width: 48px;margin-right: 6px;padding: 0px" id="vDocType" @click="restoreRemoteAndTest(index, item)">{{ getTypeName(item.Document.type, item.Document.method) }}</button>
267-
<a class="hint--rounded hint--no-animate" ref="testCaseTexts" @mouseover="setRequestHint(index, item)" href="javascript:void(0)" @click="restoreRemote(index, item)" :style="{ color: index == currentDocIndex ? 'black' : 'gray' }"> {{(item.Document.version > 0 ? 'V' + item.Document.version : 'V*') + ' ' + item.Document.name + ' ' + item.Document.url}}</a>
265+
<button class="hint--right" :data-hint="(item.Document || {}).url" v-show="isShowMethod()" style="width: 60px; margin-right: 0px;padding: 0px;" id="vDocMethod" @click="restoreRemoteAndTest(index, item)">{{ getMethodName((item.Document || {}).method, (item.Document || {}).type) }}</button>
266+
<button class="hint--right" :data-hint="(item.Document || {}).request" v-show="isShowType()" style="width: 48px;margin-right: 6px;padding: 0px" id="vDocType" @click="restoreRemoteAndTest(index, item)">{{ getTypeName((item.Document || {}).type, (item.Document || {}).method) }}</button>
267+
<a class="hint--rounded hint--no-animate" ref="testCaseTexts" @mouseover="setRequestHint(index, item)" href="javascript:void(0)" @click="restoreRemote(index, item)" :style="{ color: index == currentDocIndex ? 'black' : 'gray' }"> {{(((item.Document || {}).version || 0) > 0 ? 'V' + item.Document.version : 'V*') + ' ' + (item.Document || {}).name + ' ' + (item.Document || {}).url}}</a>
268268
<div v-show="isStatisticsEnabled" style="position: absolute; right: 31px; top: 9px; display: inline-flex">
269269
<div v-show="(item.totalCount || 0) > 0" style="background: lightgray; padding: 1px; margin-right: 2px; display: inline-block; position: relative" @click="restoreRemote(index, item, null, true)" >
270270
<!-- 只能写成一行来消除间隙,不能换行、空格 -->
@@ -411,9 +411,9 @@
411411
</div>
412412
<div id="vRequestMarkdown" v-show="isPreviewEnabled" style="width: 100%;height: 100%;position: relative;"></div>
413413

414-
<div id="vContainer" v-show="isRandomShow && isRandomListShow && currentRandomIndex >= 0 && view === 'code'" style="width: 100%; height: 100%; padding-bottom: 36px; position: absolute; z-index: 100; background-color: white; display: flex; flex-direction: column; overflow: scroll">
414+
<div id="vContainer" v-show="isRandomListShow && currentRandomIndex >= 0 && view === 'code'" style="width: 100%; height: 100%; padding-bottom: 36px; position: absolute; z-index: 100; background-color: white; display: flex; flex-direction: column; overflow: scroll">
415415
<div style="min-width: 240px; position: relative" :style="{'height': isFullScreen ? '80%' : '30%' }">
416-
<div id="vAfterTitle" style="padding: 0px 13px 0px 6px; position: absolute; width: 100%; z-index: 100" >
416+
<div id="vAfterTitle" style="padding: 0px 13px 0px 6px; position: absolute; z-index: 100" >
417417
<a style="font-weight: bold; color: black">本次: </a><a>置信度 </a><input id="vAfterThreshold" v-model="detection.afterThreshold" style="width: 24px;text-align: center" type="number" @keyup="doOnKeyUp(event, 'afterThreshold', true)" placeholder="阈值" />
418418
<a style="margin-left: -6px">% {{ detection.isShowNum ? '正确数 ' + detection.afterCorrect + ' 误报数 ' + detection.afterWrong + ' 漏检数 ' + detection.afterMiss : '召回率 ' + detection.afterRecallStr + ' 精确率 ' + detection.afterPrecisionStr + ' F1 ' + detection.afterF1Str }} </a>
419419
<a style="height: 25px; color: black; font-weight: bold; padding: 0" href="javascript:void(0)" @click="onClickFullScreen($event)" > 全屏 </a>
@@ -424,7 +424,7 @@
424424
</div>
425425
</div>
426426
<div style="min-width: 240px; position: relative; top: 25px" :style="{'height': isFullScreen ? '80%' : '30%' }">
427-
<div id="vDiffTitle" style="padding: 0px 13px 0px 6px; position: absolute; width: 100%; height: 25px; z-index: 100" >
427+
<div id="vDiffTitle" style="padding: 0px 13px 0px 6px; position: absolute; height: 25px; z-index: 100" >
428428
<a style="font-weight: bold; color: black">差异: </a><a>重合度 </a><input id="vDiffThreshold" v-model="detection.diffThreshold" style="width: 24px;text-align: center" type="number" @keyup="doOnKeyUp(event, 'diffThreshold', true)" placeholder="阈值" />
429429
<a style="margin-left: -6px">% {{ detection.isShowNum ? '正确数 ' + detection.diffCorrectStr + ' 误报数 ' + detection.diffWrongStr + ' 漏检数 ' + detection.diffMissStr : '召回率 ' + detection.diffRecallStr + ' 精确率 ' + detection.diffPrecisionStr + ' F1 ' + detection.diffF1Str }} </a>
430430
</div>
@@ -434,7 +434,7 @@
434434
</div>
435435
</div>
436436
<div style="min-width: 240px; position: relative; top: 50px" :style="{'height': isFullScreen ? '80%' : '30%' }">
437-
<div id="vBeforeTitle" style="padding: 0px 13px 0px 6px; position: absolute; width: 100%; z-index: 100" >
437+
<div id="vBeforeTitle" style="padding: 0px 13px 0px 6px; position: absolute; z-index: 100" >
438438
<a style="font-weight: bold; color: black">之前: </a><a>置信度 </a><input id="vBeforeThreshold" v-model="detection.beforeThreshold" style="width: 24px;text-align: center" type="number" @keyup="doOnKeyUp(event, 'beforeThreshold', true)" placeholder="阈值" disabled />
439439
<a style="margin-left: -6px">% {{ detection.isShowNum ? '正确数 ' + detection.beforeCorrect + ' 误报数 ' + detection.beforeWrong + ' 漏检数 ' + detection.beforeMiss : '召回率 ' + detection.beforeRecallStr + ' 精确率 ' + detection.beforePrecisionStr + ' F1 ' + detection.beforeF1Str }} </a>
440440
<a > 实际 </a><input id="vAfterTotal" v-model="detection.total" style="width: 36px;text-align: center" type="number" @keyup="doOnKeyUp(event, 'afterTotal', true)" placeholder="总数" />

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/cv/js/main.js

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ https://github.com/Tencent/APIJSON/issues
22662266
for (var i = 0; i < apis.length; i++) {
22672267
var item = apis[i]
22682268
var req = item == null ? null : item.request
2269-
var urlObj = req.url || {}
2269+
var urlObj = (req == null ? null : req.url) || {}
22702270
var path = urlObj.path
22712271
var url = path instanceof Array ? '/' + path.join('/') : (typeof urlObj == 'string' ? urlObj : urlObj.raw)
22722272
if (StringUtil.isEmpty(url, true)) {
@@ -5665,6 +5665,7 @@ https://github.com/Tencent/APIJSON/issues
56655665
// }
56665666

56675667
//App.onChange(false)
5668+
App.summary()
56685669
}
56695670
},
56705671

@@ -7038,7 +7039,11 @@ https://github.com/Tencent/APIJSON/issues
70387039
detection[stage + 'PrecisionStr'] = (100*precision).toFixed(0) + '%';
70397040
detection[stage + 'F1Str'] = (100*f1).toFixed(0) + '%';
70407041
})
7042+
},
70417043

7044+
summary: function() {
7045+
const detection = this.detection || {};
7046+
var total = detection.total;
70427047
if (total <= 0) {
70437048
detection.total = total = detection.afterCorrect || detection.beforeCorrect;
70447049
}
@@ -7220,7 +7225,7 @@ https://github.com/Tencent/APIJSON/issues
72207225
.replaceAll(/'new'/ig, '').replaceAll('测试', '')
72217226
.replaceAll('未命名', '').replaceAll('未知', '')
72227227
.replaceAll('示例', '').replaceAll('新建', '')
7223-
.replaceAll('图片', '');
7228+
.replaceAll('图片', '').replaceAll('照片', '').replaceAll('相片', '');
72247229

72257230
var dotInd = file.lastIndexOf('.');
72267231
file = dotInd >= 0 ? file.substring(0, dotInd).trim() : file.trim();
@@ -7305,13 +7310,13 @@ https://github.com/Tencent/APIJSON/issues
73057310
});
73067311

73077312
// 如果需要也展示 before 中 unmatched 的box,可遍历 beforeBoxes 进行差异补充
7308-
var diff = this.detection.diff || {};
7313+
var diff = detection.diff || {};
73097314
diff.bboxes = diffBoxes;
7310-
this.$set(this.detection, 'diff', { bboxes: diffBoxes });
7311-
this.$set(this.detection, 'after', { bboxes: afterBoxes }); // 确保 after 被更新到 Vue
7315+
detection.diff = diff;
7316+
this.detection = detection;
7317+
73127318
this.drawAll();
73137319
this.compute();
7314-
this.detection.diff = diff;
73157320
return diff;
73167321
},
73177322

@@ -7348,24 +7353,41 @@ https://github.com/Tencent/APIJSON/issues
73487353
const img = this.imgMap[stage];
73497354
const canvas = this.canvasMap[stage];
73507355
const [x, y] = this.getCanvasXY(stage, event);
7356+
7357+
const height = canvas.height || (img || {}).height;
7358+
const width = canvas.width || (img || {}).width;
7359+
const nw = img == null ? 0 : (img.naturalWidth || 0);
7360+
const nh = img == null ? 0 : (img.naturalHeight || 0);
7361+
const xRate = nw < 1 ? 1 : width/nw;
7362+
const yRate = nh < 1 ? 1 : height/nh;
7363+
73517364
let found = null;
73527365
var bboxes = JSONResponse.getBboxes(this.detection[stage]) || []
73537366
let len = bboxes.length;
7354-
var range = ((canvas || {}).height || (img || {}).height || 240) * (len <= 1 ? 0.5 : (len <= 5 ? 0.1/len : 0.02));
7355-
for (const item of bboxes) {
7356-
var bbox = JSONResponse.getXYWHD(JSONResponse.getBbox(item));
7357-
if (JSONResponse.isOnBorder(x, y, bbox, range)) {
7358-
found = item.id;
7367+
var range = (height || 240) * (len <= 1 ? 0.5 : (len <= 5 ? 0.1/len : 0.02));
7368+
for (var i = 0; i < len; i++) {
7369+
const item = bboxes[i];
7370+
if (item == null) {
7371+
continue;
7372+
}
7373+
7374+
var [bx, by, bw, bh, bd] = JSONResponse.getXYWHD(JSONResponse.getBbox(item));
7375+
const isRate = Math.abs(bx) < 1 && Math.abs(by) < 1 && Math.abs(bw) < 1 && Math.abs(bh) < 1;
7376+
bx = isRate ? bx*width : bx*xRate;
7377+
by = isRate ? by*height : by*yRate;
7378+
bw = isRate ? bw*width : bw*xRate;
7379+
bh = isRate ? bh*height : bh*yRate;
7380+
if (JSONResponse.isOnBorder(x, y, [bx, by, bw, bh, bd], range)) {
7381+
found = i;
73597382
break;
73607383
}
73617384
}
73627385

7363-
if (found == null || found == this.hoverIds[stage]) {
7386+
if (found == this.hoverIds[stage]) {
73647387
return
73657388
}
73667389

73677390
this.hoverIds[stage] = found;
7368-
this.$set(this.hoverIds, stage, found);
73697391
this.draw(stage);
73707392
},
73717393
onClickFullScreen: function(event) {
@@ -7388,6 +7410,14 @@ https://github.com/Tencent/APIJSON/issues
73887410
const img = this.imgMap[stage];
73897411
const canvas = this.canvasMap[stage];
73907412
const [x, y] = this.getCanvasXY(stage, event);
7413+
7414+
const height = canvas.height || (img || {}).height;
7415+
const width = canvas.width || (img || {}).width;
7416+
const nw = img == null ? 0 : (img.naturalWidth || 0);
7417+
const nh = img == null ? 0 : (img.naturalHeight || 0);
7418+
const xRate = nw < 1 ? 1 : width/nw;
7419+
const yRate = nh < 1 ? 1 : height/nh;
7420+
73917421
const corrects = detection.corrects = detection.corrects || [];
73927422
const wrongs = detection.wrongs = detection.wrongs || [];
73937423

@@ -7400,7 +7430,12 @@ https://github.com/Tencent/APIJSON/issues
74007430
continue;
74017431
}
74027432

7403-
const [bx, by, bw, bh, d] = JSONResponse.getXYWHD(JSONResponse.getBbox(item));
7433+
var [bx, by, bw, bh, bd] = JSONResponse.getXYWHD(JSONResponse.getBbox(item));
7434+
const isRate = Math.abs(bx) < 1 && Math.abs(by) < 1 && Math.abs(bw) < 1 && Math.abs(bh) < 1;
7435+
bx = isRate ? bx*width : bx*xRate;
7436+
by = isRate ? by*height : by*yRate;
7437+
bw = isRate ? bw*width : bw*xRate;
7438+
bh = isRate ? bh*height : bh*yRate;
74047439

74057440
// 无效
74067441
// const labelX = bx + bw + 4; // 和 drawDetections 中计算按钮位置保持一致
@@ -10404,9 +10439,8 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1040410439
getDoc4TestCase: function () {
1040510440
var list = this.remotes || []
1040610441
var doc = ''
10407-
var item
1040810442
for (var i = 0; i < list.length; i ++) {
10409-
item = list[i] == null ? null : list[i].Document
10443+
var item = list[i] == null ? null : list[i].Document
1041010444
if (item == null || item.name == null) {
1041110445
continue
1041210446
}
@@ -12818,6 +12852,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1281812852
// }
1281912853

1282012854
App.updateTestRecord(0, list, index, item, rawRspStr == null ? null : parseJSON(rawRspStr), isRandom, true, App.currentAccountIndex, isCross)
12855+
App.summary()
1282112856
}
1282212857

1282312858
})

0 commit comments

Comments
 (0)