|
@@ -13,7 +13,7 @@
|
|
|
<div class="common-layout">
|
|
|
<el-container>
|
|
|
<el-input type="file" v-model="fileName" @change="uploadImg"></el-input>
|
|
|
- <el-button type="primary" @click="predict">Predict</el-button>
|
|
|
+ <el-button type="primary" @click="predict" :loading="loading">Predict</el-button>
|
|
|
</el-container>
|
|
|
</div>
|
|
|
<div v-show="is_pdf">
|
|
@@ -279,7 +279,7 @@ const uploadImg = () => {
|
|
|
|
|
|
type RectWithId = fabric.Rect & { id: number };
|
|
|
|
|
|
-function CreateRect(canvas: any, i: number, left: number, top: number, width: number, height: number, highlight: boolean) {
|
|
|
+function CreateRect(canvas: any, i: number, left: number, top: number, width: number, height: number, highlight: boolean, label: number) {
|
|
|
var rect = new fabric.Rect({
|
|
|
left: left,
|
|
|
top: top,
|
|
@@ -293,6 +293,27 @@ function CreateRect(canvas: any, i: number, left: number, top: number, width: nu
|
|
|
name: highlight ? 'high' : 'normal',
|
|
|
}) as RectWithId;
|
|
|
rect.set('id', i);
|
|
|
+ // rect.on('mouseup', function () {
|
|
|
+ // if (label == 1) {
|
|
|
+ // figureSelectedItem.value = i;
|
|
|
+ // } else if (label == 2) {
|
|
|
+ // tableSelectedItem.value = i;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // let objects = fa_canvas.getObjects();
|
|
|
+ // for (let i = 0; i < objects.length; i++) {
|
|
|
+ // if (objects[i].name === 'high') {
|
|
|
+ // // 找到名为 rectName 的矩形元素,执行删除操作等
|
|
|
+ // fa_canvas.remove(objects[i]);
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (label == 1) {
|
|
|
+ // CreateRect(fa_canvas, i, figure_rects[i].left, figure_rects[i].top, figure_rects[i].width, figure_rects[i].height, true, label);
|
|
|
+ // } else if (label == 2) {
|
|
|
+ // CreateRect(fa_canvas, i, table_rects[i].left, table_rects[i].top, table_rects[i].width, table_rects[i].height, true, label);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
canvas.add(rect);
|
|
|
}
|
|
|
|
|
@@ -341,11 +362,12 @@ const predict = async () => {
|
|
|
if (tmp_labels[i] == "Figure") {
|
|
|
figureArr.value.push("图片" + String(figureArr.value.length + 1));
|
|
|
figure_rects.push(rect);
|
|
|
+ CreateRect(fa_canvas, i, left, top, width, height, false, 1);
|
|
|
} else if (tmp_labels[i] == "Table_0" || tmp_labels[i] == "Table_std") {
|
|
|
tableArr.value.push("表格" + String(tableArr.value.length + 1));
|
|
|
table_rects.push(rect);
|
|
|
+ CreateRect(fa_canvas, i, left, top, width, height, false, 2);
|
|
|
}
|
|
|
- CreateRect(fa_canvas, i, left, top, width, height, false);
|
|
|
}
|
|
|
// if (figureArr.value.length == 0)
|
|
|
// figureArr.value.push("无");
|
|
@@ -390,11 +412,12 @@ const predict = async () => {
|
|
|
if (tmp_labels[i] == "Figure") {
|
|
|
figureArr.value.push("图片");
|
|
|
figure_rects.push(rect);
|
|
|
+ CreateRect(fa_canvas, i, left, top, width, height, false, 1);
|
|
|
} else if (tmp_labels[i] == "Table_0" || tmp_labels[i] == "Table_std") {
|
|
|
tableArr.value.push("表格(" + tmp_labels[i] + ")");
|
|
|
table_rects.push(rect);
|
|
|
+ CreateRect(fa_canvas, i, left, top, width, height, false, 2);
|
|
|
}
|
|
|
- CreateRect(fa_canvas, i, left, top, width, height, false);
|
|
|
}
|
|
|
figureArr.value.reverse();
|
|
|
tableArr.value.reverse();
|
|
@@ -448,7 +471,7 @@ async function figureHandleClick(index: any, item: any, rects: any) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- CreateRect(fa_canvas, index, rects[index].left, rects[index].top, rects[index].width, rects[index].height, true);
|
|
|
+ CreateRect(fa_canvas, index, rects[index].left, rects[index].top, rects[index].width, rects[index].height, true, 1);
|
|
|
}
|
|
|
|
|
|
async function tableHandleClick(index: any, item: any, rects: any) {
|
|
@@ -462,7 +485,7 @@ async function tableHandleClick(index: any, item: any, rects: any) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- CreateRect(fa_canvas, index, rects[index].left, rects[index].top, rects[index].width, rects[index].height, true);
|
|
|
+ CreateRect(fa_canvas, index, rects[index].left, rects[index].top, rects[index].width, rects[index].height, true, 2);
|
|
|
}
|
|
|
</script>
|
|
|
|