Эх сурвалжийг харах

feat: 黑点检测工具测试

zhangjie 8 сар өмнө
parent
commit
366c28a8ab

+ 5 - 6
src/plugins/imageOcr.js

@@ -94,15 +94,13 @@ function checkImageAnswerArea(imgPath, codeArea) {
       let code;
       try {
         const DecodeResult = childProcess.execSync(`${exec} ${tmpFile}`);
-        console.log(DecodeResult.toString());
+        // console.log(DecodeResult.toString());
         const codes = DecodeResult.toString()
           .replace(/\r/, "")
           .replace(/\n/, "")
           .split(":");
-        console.dir(codes);
-        if (codes.length <= 2) {
-          code = codes[codes.length - 1].replace(/\s+/g, "");
-        }
+        // console.dir(codes);
+        code = codes[0];
         console.log(code);
       } catch (e) {
         console.log(e);
@@ -366,5 +364,6 @@ export {
   compressImage,
   downloadFile,
   downloadServerFile,
-  checkEmptyCoverFilled
+  checkEmptyCoverFilled,
+  checkImageAnswerArea
 };

+ 6 - 0
src/router.js

@@ -5,6 +5,7 @@ import Home from "./views/Home";
 import Layout from "./views/Layout";
 import Login from "./views/Login";
 import ImageCheck from "./modules/manage/views/ImageCheck";
+import Test from "./views/Test.vue";
 
 // modules
 import client from "./modules/client/router";
@@ -26,6 +27,11 @@ export default new Router({
       name: "Index",
       redirect: { name: "Login" }
     },
+    {
+      path: "/test",
+      name: "Test",
+      component: Test
+    },
     {
       path: "/image-check",
       name: "ImageCheck",

+ 34 - 0
src/views/Test.vue

@@ -0,0 +1,34 @@
+<template>
+  <div class="test">
+    <Button size="large" type="primary" @click="toTestBlackCheck"
+      >测试blackCheck</Button
+    >
+  </div>
+</template>
+
+<script>
+import { checkImageAnswerArea } from "../plugins/imageOcr";
+import { getStoresDir } from "../plugins/env";
+
+export default {
+  name: "test",
+  data() {
+    return {};
+  },
+  methods: {
+    async toTestBlackCheck() {
+      const imgPath = getStoresDir("test.jpg");
+      const codeArea = {
+        width: 500,
+        height: 500,
+        x: 100,
+        y: 100
+      };
+      const result = await checkImageAnswerArea(imgPath, codeArea).catch(e => {
+        console.error(e);
+      });
+      console.log(result);
+    }
+  }
+};
+</script>