Browse Source

[web_demo] fix bug,优化图片清晰度

yanxin 1 year ago
parent
commit
9f50f3d921

File diff suppressed because it is too large
+ 1276 - 37
package-lock.json


File diff suppressed because it is too large
+ 49 - 49
src/dist/assets/index-52c7fb66.js


File diff suppressed because it is too large
+ 1 - 1
src/dist/assets/index-c0e641eb.css


+ 2 - 2
src/dist/index.html

@@ -4,8 +4,8 @@
     <meta charset="UTF-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>DocumentAI Web Demo</title>
-    <script type="module" crossorigin src="./assets/index-52c7fb66.js"></script>
-    <link rel="stylesheet" href="./assets/index-c0e641eb.css">
+    <script type="module" crossorigin src="./assets/index-42269111.js"></script>
+    <link rel="stylesheet" href="./assets/index-9585a3a9.css">
   </head>
   <body>
     <div id="app"></div>

+ 11 - 1
src/pages/main/views/Detection/LayoutAnalysis.vue

@@ -134,7 +134,7 @@ function getPdfImage(index: number) {
   loadingTask.promise.then((pdf: any) => {
     state.numPages = pdf.numPages;
     pdf.getPage(index).then((page: any) => {
-      const viewport = page.getViewport({ scale: 1.0 })
+      const viewport = page.getViewport({ scale: 2.0 })
       img_canvas.value.height = viewport.height;
       img_canvas.value.width = viewport.width;
       canvas.value.height = viewport.height;
@@ -158,7 +158,12 @@ function getPdfImage(index: number) {
         showImg.onload = () => {
           canvas.value.width = showImg.width;
           canvas.value.height = showImg.height;
+          if (fa_canvas != null) {
+            fa_canvas.dispose();
+            fa_canvas = null;
+          }
           fa_canvas = new fabric.Canvas(canvas.value);
+          fa_canvas.clear()
           figure_rects.splice(0)
           table_rects.splice(0)
           figureSelectedItem.value = -1;
@@ -271,7 +276,12 @@ const beforeUpload = (file: File): boolean | Promise<boolean> => {
       showImg.onload = () => {
         canvas.value.width = showImg.width;
         canvas.value.height = showImg.height;
+        if (fa_canvas != null) {
+          fa_canvas.dispose();
+          fa_canvas = null;
+        }
         fa_canvas = new fabric.Canvas(canvas.value);
+        fa_canvas.clear()
         figure_rects.splice(0)
         table_rects.splice(0)
         figureSelectedItem.value = -1;

+ 1 - 1
src/pages/main/views/ImageProcess/magicColor.vue

@@ -121,7 +121,7 @@ function getPdfImage(index: number) {
   loadingTask.promise.then((pdf: any) => {
     state.numPages = pdf.numPages;
     pdf.getPage(index).then((page: any) => {
-      const viewport = page.getViewport({ scale: 1.0 })
+      const viewport = page.getViewport({ scale: 2.0 })
       canvas.value.height = viewport.height;
       canvas.value.width = viewport.width;
       const destWidth = 398;

+ 11 - 1
src/pages/main/views/Recognize/ocr.vue

@@ -141,7 +141,7 @@ function getPdfImage(index: number) {
   loadingTask.promise.then((pdf: any) => {
     state.numPages = pdf.numPages;
     pdf.getPage(index).then((page: any) => {
-      const viewport = page.getViewport({ scale: 1.0 })
+      const viewport = page.getViewport({ scale: 2.0 })
       img_canvas.value.height = viewport.height;
       img_canvas.value.width = viewport.width;
       canvas.value.height = viewport.height;
@@ -165,7 +165,12 @@ function getPdfImage(index: number) {
         showImg.onload = () => {
           canvas.value.width = showImg.width;
           canvas.value.height = showImg.height;
+          if (fa_canvas != null) {
+            fa_canvas.dispose();
+            fa_canvas = null;
+          }
           fa_canvas = new fabric.Canvas(canvas.value);
+          fa_canvas.clear()
           rects.splice(0)
           selectedItem.value = -1;
         }
@@ -296,7 +301,12 @@ const beforeUpload = (file: File): boolean | Promise<boolean> => {
       showImg.onload = () => {
         canvas.value.width = showImg.width;
         canvas.value.height = showImg.height;
+        if (fa_canvas != null) {
+          fa_canvas.dispose();
+          fa_canvas = null;
+        }
         fa_canvas = new fabric.Canvas(canvas.value);
+        fa_canvas.clear()
         rects.splice(0)
         selectedItem.value = -1;
       }

+ 1 - 1
src/pages/main/views/Recognize/tableRec.vue

@@ -302,7 +302,7 @@ function getPdfImage(index: number) {
   loadingTask.promise.then((pdf: any) => {
     state.numPages = pdf.numPages;
     pdf.getPage(index).then((page: any) => {
-      const viewport = page.getViewport({ scale: 1.0 })
+      const viewport = page.getViewport({ scale: 2.0 })
       canvas.value.height = viewport.height;
       canvas.value.width = viewport.width;
       const destWidth = 398;