Browse Source

测试ocr api接口

yanxin 2 years ago
parent
commit
e603097c2a
3 changed files with 17 additions and 17 deletions
  1. 2 2
      src/api/api.ts
  2. 1 1
      src/api/index.ts
  3. 14 14
      src/pages/main/views/Recognize/ocr.vue

+ 2 - 2
src/api/api.ts

@@ -20,9 +20,9 @@ interface OcrRecRes {
 }
 
 export const IMMagicColor = (data: InputData): Promise<PredictRes<MagciColorRes>> =>
-  server.post("/IM/magicColor", data);
+  server.post("/magicColor", data);
 
 export const OcrRec = (data: InputData): Promise<PredictRes<OcrRecRes>> =>
-  server.post("/Ocr/ocr", data);
+  server.post("/ocr", data);
 
 export {};

+ 1 - 1
src/api/index.ts

@@ -1,7 +1,7 @@
 import axios from "axios";
 
 const server = axios.create({
-  baseURL: "192.168.10.10:80",
+  baseURL: "http://localhost:3000",
 });
 
 server.interceptors.request.use(

+ 14 - 14
src/pages/main/views/Recognize/ocr.vue

@@ -97,21 +97,21 @@ const predict = async () => {
   const file = inputElement.files![0];
 
   loading.value = !loading.value
-  setTimeout(() => {
-    loading.value = !loading.value
-    predictImg.src = "https://cdn.pixabay.com/photo/2021/03/14/18/03/cat-6095007_1280.jpg"
-    predictTime.value = Math.ceil(Math.random() * 10);
-  }, 2000);
-
-  // OcrRec({
-  //   image: file,
-  // }).then(res => {
-  //   console.log(res.code)
-  //   predictImg.src = res.image
-  //   predictTime.value = res.costTime
-  //   result.value = res.text.reduce((total, cur) => total + `<p>${cur}</p>`);
+  // setTimeout(() => {
   //   loading.value = !loading.value
-  // })
+  //   predictImg.src = "https://cdn.pixabay.com/photo/2021/03/14/18/03/cat-6095007_1280.jpg"
+  //   predictTime.value = Math.ceil(Math.random() * 10);
+  // }, 2000);
+
+  OcrRec({
+    image: file,
+  }).then(res => {
+    console.log(res.code)
+    predictImg.src = res.data.image
+    predictTime.value = res.costTime
+    result.value = res.data.text.reduce((total, cur) => total + `<p>${cur}</p>`);
+    loading.value = !loading.value
+  })
 };
 
 </script>