Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f4cfda7

Browse files
CVAuto:线段用 [x1, y1, x2, y2] 格式画,对错 √ x 放到标签左侧避免被遮挡
1 parent afb0f37 commit f4cfda7

File tree

1 file changed

+35
-20
lines changed
  • APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/cv/apijson

1 file changed

+35
-20
lines changed

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

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,11 +2284,29 @@ var JSONResponse = {
22842284

22852285
var x = bbox.x || bbox.x0 || bbox.x1 || bbox.startX || bbox.xStart || bbox.leftTopX || bbox.topLeftX || bbox.start_x || bbox.x_start || bbox.left_top_x || bbox.top_left_x || 0;
22862286
var y = bbox.y || bbox.y0 || bbox.y1 || bbox.startY || bbox.yStart || bbox.leftTopY || bbox.topLeftY || bbox.start_y || bbox.y_start || bbox.left_top_y || bbox.top_left_y || 0;
2287-
var w = bbox.w || bbox.width || ((bbox.x2 || bbox.x1 || bbox.rbx || bbox.brx || bbox.endX || bbox.xEnd || bbox.rightBottomX || bbox.bottomRightX || bbox.end_x || bbox.x_end || bbox.right_bottom_x || bbox.bottom_right_x || 0) - x);
2288-
var h = bbox.h || bbox.height || ((bbox.y2 || bbox.y1 || bbox.rby || bbox.bry || bbox.endY || bbox.yEnd || bbox.rightBottomY || bbox.bottomRightY || bbox.end_y || bbox.y_end || bbox.right_bottom_y || bbox.bottom_right_y || 0) - y);
2287+
var w = bbox.width || bbox.w || ((bbox.x2 || bbox.x1 || bbox.rbx || bbox.brx || bbox.endX || bbox.xEnd || bbox.rightBottomX || bbox.bottomRightX || bbox.end_x || bbox.x_end || bbox.right_bottom_x || bbox.bottom_right_x || 0) - x);
2288+
var h = bbox.height || bbox.h || ((bbox.y2 || bbox.y1 || bbox.rby || bbox.bry || bbox.endY || bbox.yEnd || bbox.rightBottomY || bbox.bottomRightY || bbox.end_y || bbox.y_end || bbox.right_bottom_y || bbox.bottom_right_y || 0) - y);
22892289
var d = bbox.degree || bbox.angle || bbox.rotate || bbox.perspective || bbox.d || bbox.r || bbox.p || bbox.a;
22902290
return [+ (x || 0), + (y || 0), + (w || 0), + (h || 0), + (d || 0)];
22912291
},
2292+
getXYXYD: function (bbox) {
2293+
if (bbox == null) {
2294+
return null;
2295+
}
2296+
if (JSONResponse.isString(bbox)) {
2297+
bbox = StringUtil.split(bbox, ',', true);
2298+
}
2299+
if (bbox instanceof Array) {
2300+
return [+ (bbox[0] || 0), + (bbox[1] || 0), + (bbox[2] || 0), + (bbox[3] || 0), + (bbox[4] || 0)];
2301+
}
2302+
2303+
var x = bbox.x || bbox.x0 || bbox.x1 || bbox.startX || bbox.xStart || bbox.leftTopX || bbox.topLeftX || bbox.start_x || bbox.x_start || bbox.left_top_x || bbox.top_left_x || 0;
2304+
var y = bbox.y || bbox.y0 || bbox.y1 || bbox.startY || bbox.yStart || bbox.leftTopY || bbox.topLeftY || bbox.start_y || bbox.y_start || bbox.left_top_y || bbox.top_left_y || 0;
2305+
var x2 = bbox.x2 || bbox.x1 || bbox.rbx || bbox.brx || bbox.endX || bbox.xEnd || bbox.rightBottomX || bbox.bottomRightX || bbox.end_x || bbox.x_end || bbox.right_bottom_x || bbox.bottom_right_x || ((bbox.width || bbox.w || 0) + x);
2306+
var y2 = bbox.y2 || bbox.y1 || bbox.rby || bbox.bry || bbox.endY || bbox.yEnd || bbox.rightBottomY || bbox.bottomRightY || bbox.end_y || bbox.y_end || bbox.right_bottom_y || bbox.bottom_right_y || ((bbox.height || bbox.h || 0) + y);
2307+
var d = bbox.degree || bbox.angle || bbox.rotate || bbox.perspective || bbox.d || bbox.r || bbox.p || bbox.a;
2308+
return [+ (x || 0), + (y || 0), + (x2 || 0), + (y2 || 0), + (d || 0)];
2309+
},
22922310
/**
22932311
* 计算两个 bbox([x, y, w, h, r])的 IoU
22942312
*/
@@ -2528,7 +2546,7 @@ var JSONResponse = {
25282546
}
25292547

25302548
const [r, g, b, a] = color || [0, 255, 0, 255];
2531-
const rgba = `rgba(${r}, ${g}, ${b}, ${hoverBoxId != null || ! isHovered ? 0.3 : Math.min(0.5, a < 1 ? a : a / 255)})`;
2549+
const rgba = `rgba(${r}, ${g}, ${b}, ${hoverBoxId != null && ! isHovered ? 0.3 : Math.min(0.5, a < 1 ? a : a / 255)})`;
25322550

25332551
const reversedRgba = `rgba(${255 - r}, ${255 - g}, ${255 - b}, ${isHovered || hoverBoxId == null ? 1 : 0.3})`;
25342552
// const luma = 0.299 * r + 0.587 * g + 0.114 * b;
@@ -2553,8 +2571,16 @@ var JSONResponse = {
25532571
return
25542572
}
25552573

2574+
is_before = item['@before'];
2575+
mark = '';
2576+
if (markable && is_before != true) {
2577+
const isWrong = wrongs.indexOf(isDiff ? item['@index'] : index) >= 0; // item.correct === false;
2578+
// 绘制 √ 和 ×ばつ
2579+
mark = isWrong ? ×ばつ ' : '✓ ';
2580+
}
2581+
25562582
// Label
2557-
const label = (isDiff ? (item['@before'] ? '- ' : '+ ') : '') + `${item.ocr || item.label || ''}-${item.id || ''} ${((JSONResponse.getScore(item) || 0)*100).toFixed(0)}%${angle == 0 ? '' : ' ' + Math.round(angle) + '°'}`;
2583+
const label = mark+(isDiff ? (is_before ? '- ' : '+ ') : '') + `${item.ocr || item.label || ''}-${item.id || ''} ${((JSONResponse.getScore(item) || 0)*100).toFixed(0)}%${angle == 0 ? '' : ' ' + Math.round(angle) + '°'}`;
25582584
// ctx.font = 'bold 36px';
25592585
// const size = ctx.measureText(label);
25602586
// const textHeight = size.height || height*0.1; // Math.max(height*0.1, size.height);
@@ -2606,17 +2632,6 @@ var JSONResponse = {
26062632
ctx.fillText(label, labelX, labelY);
26072633
ctx.restore();
26082634

2609-
if (markable && item['@before'] != true) {
2610-
const isWrong = wrongs.indexOf(isDiff ? item['@index'] : index) >= 0; // item.correct === false;
2611-
// 绘制 √ 和 ×ばつ
2612-
ctx.font = `bold ${fontSize}px sans-serif`;
2613-
// ctx.fillStyle = isWrong ? 'red' : 'green';
2614-
ctx.fillStyle = isWrong ? 'red' : 'green';
2615-
const checkX = labelX + textWidth + 4;
2616-
const checkY = labelY;
2617-
ctx.fillText(isWrong ? ×ばつ' : '√', checkX, checkY);
2618-
}
2619-
26202635
JSONResponse.drawDetections(canvas, item, options, img, ctx);
26212636
});
26222637
}
@@ -2629,12 +2644,12 @@ var JSONResponse = {
26292644
return;
26302645
}
26312646

2632-
var [x, y, w,h, d] = JSONResponse.getXYWHD(item);
2633-
const isRate = Math.abs(x) < 1 && Math.abs(y) < 1 && Math.abs(w) < 1 && Math.abs(h) < 1;
2647+
var [x, y, x2,y2, d] = JSONResponse.getXYXYD(item);
2648+
const isRate = Math.abs(x) < 1 && Math.abs(y) < 1 && Math.abs(x2) < 1 && Math.abs(y2) < 1;
26342649
x = isRate ? x*width : x*xRate;
26352650
y = isRate ? y*height : y*yRate;
2636-
w = isRate ? w*width : w*xRate;
2637-
h = isRate ? h*height : h*yRate;
2651+
x2 = isRate ? x2*width : x2*xRate;
2652+
y2 = isRate ? y2*height : y2*yRate;
26382653

26392654
const color = item.color || detection.color || detection.bbox?.color;
26402655
const rgba = color == null || color.length <= 0 ? null : `rgba(${color.join(',')})`;
@@ -2645,7 +2660,7 @@ var JSONResponse = {
26452660

26462661
ctx.beginPath();
26472662
ctx.moveTo(x, y);
2648-
ctx.lineTo(x+w,y+h);
2663+
ctx.lineTo(x2,y2);
26492664
ctx.stroke();
26502665

26512666
if (isRoot) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /