From 161f8f469ab6883dc5621a3080bb7b97cea2c221 Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Thu, 18 Mar 2021 17:09:09 +0800 Subject: [PATCH] ocr --- ocr/pom.xml | 35 ++++ .../java/com/ccsens/orc/OcrApplication.java | 24 +++ ocr/src/main/resources/application-common.yml | 28 +++ ocr/src/main/resources/application-dev.yml | 41 ++++ .../resources/application-greenvalley.yml | 39 ++++ ocr/src/main/resources/application-prod.yml | 48 +++++ .../main/resources/application-prodapi.yml | 44 ++++ ocr/src/main/resources/application-prodsd.yml | 44 ++++ ocr/src/main/resources/application-test.yml | 51 +++++ ocr/src/main/resources/application.yml | 5 + ocr/src/main/resources/banner.txt | 21 ++ ocr/src/main/resources/logback-spring.xml | 196 ++++++++++++++++++ .../java/com/ccsens/orc/test/OrcTest.java | 44 ++++ pom.xml | 1 + 14 files changed, 621 insertions(+) create mode 100644 ocr/pom.xml create mode 100644 ocr/src/main/java/com/ccsens/orc/OcrApplication.java create mode 100644 ocr/src/main/resources/application-common.yml create mode 100644 ocr/src/main/resources/application-dev.yml create mode 100644 ocr/src/main/resources/application-greenvalley.yml create mode 100644 ocr/src/main/resources/application-prod.yml create mode 100644 ocr/src/main/resources/application-prodapi.yml create mode 100644 ocr/src/main/resources/application-prodsd.yml create mode 100644 ocr/src/main/resources/application-test.yml create mode 100644 ocr/src/main/resources/application.yml create mode 100644 ocr/src/main/resources/banner.txt create mode 100644 ocr/src/main/resources/logback-spring.xml create mode 100644 ocr/src/test/java/com/ccsens/orc/test/OrcTest.java diff --git a/ocr/pom.xml b/ocr/pom.xml new file mode 100644 index 00000000..b9200524 --- /dev/null +++ b/ocr/pom.xml @@ -0,0 +1,35 @@ + + + + ccsenscloud + com.ccsens + 1.0-SNAPSHOT + + 4.0.0 + + ocr + + + + + cloudutil + com.ccsens + 1.0-SNAPSHOT + + + + util + com.ccsens + 1.0-SNAPSHOT + + + + org.bytedeco.javacpp-presets + opencv + 4.0.1-1.4.4 + + + + \ No newline at end of file diff --git a/ocr/src/main/java/com/ccsens/orc/OcrApplication.java b/ocr/src/main/java/com/ccsens/orc/OcrApplication.java new file mode 100644 index 00000000..d1c1c8e2 --- /dev/null +++ b/ocr/src/main/java/com/ccsens/orc/OcrApplication.java @@ -0,0 +1,24 @@ +package com.ccsens.orc; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableAsync; + +/** + * @description: + * @author: whj + * @time: 2021/3/17 15:41 + */ + +@MapperScan(basePackages = {"com.ccsens.ocr.persist.*"}) +@ServletComponentScan +@EnableAsync +//开启断路器功能 +@EnableCircuitBreaker +@EnableFeignClients(basePackages = "com.ccsens.cloudutil.feign") +@SpringBootApplication(scanBasePackages = "com.ccsens") +public class OcrApplication { +} diff --git a/ocr/src/main/resources/application-common.yml b/ocr/src/main/resources/application-common.yml new file mode 100644 index 00000000..c27ac934 --- /dev/null +++ b/ocr/src/main/resources/application-common.yml @@ -0,0 +1,28 @@ +logging: + level: + com: + favorites: DEBUG + org: + hibernate: ERROR + springframework: + web: DEBUG +mybatis: + config-location: classpath:mybatis/mybatis-config.xml + mapper-locations: classpath*:mapper_*/*.xml + type-aliases-package: com.ccsens.ht.bean +server: + tomcat: + uri-encoding: UTF-8 +spring: + http: + encoding: + charset: UTF-8 + enabled: true + force: true + log-request-details: true + servlet: + multipart: + max-file-size: 10MB + max-request-size: 100MB + + diff --git a/ocr/src/main/resources/application-dev.yml b/ocr/src/main/resources/application-dev.yml new file mode 100644 index 00000000..8cb2dc85 --- /dev/null +++ b/ocr/src/main/resources/application-dev.yml @@ -0,0 +1,41 @@ +server: + port: 7030 + servlet: + context-path: /v1.0 +spring: + snowflake: + datacenterId: 1 + workerId: 1 + application: + name: tall + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: 192.168.0.99 + password: guest + port: 5672 + username: guest + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true + +gatewayUrl: https://test.tall.wiki/gateway/ +notGatewayUrl: /home/staticrec/logo.png +smsCode: 0 +wx: + prefixUrl: https://test.tall.wiki/wxconfigurer-api/ +file: + path: /home/cloud/tall/uploads/ + domain: http://localhost:7030/v1.0/ + imgDomain: http://localhost:7030/v1.0/uploads \ No newline at end of file diff --git a/ocr/src/main/resources/application-greenvalley.yml b/ocr/src/main/resources/application-greenvalley.yml new file mode 100644 index 00000000..fa815963 --- /dev/null +++ b/ocr/src/main/resources/application-greenvalley.yml @@ -0,0 +1,39 @@ +server: + port: 7030 + servlet: + context-path: /v1.0 +spring: + snowflake: + datacenterId: 1 + workerId: 1 + application: + name: tall + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: 127.0.0.1 + password: admin + port: 5672 + username: 111111 + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true +eureka: + instance: + ip-address: 82.156.116.247 +gatewayUrl: http://82.156.116.247 /gateway/ +notGatewayUrl: http://82.156.116.247 / +file: + domain: http://82.156.116.247 /gateway/tall/v1.0/ + imgDomain: http://82.156.116.247 /gateway/tall/v1.0/uploads \ No newline at end of file diff --git a/ocr/src/main/resources/application-prod.yml b/ocr/src/main/resources/application-prod.yml new file mode 100644 index 00000000..48426ae3 --- /dev/null +++ b/ocr/src/main/resources/application-prod.yml @@ -0,0 +1,48 @@ +server: + port: 7030 + servlet: + context-path: /v1.0 +spring: + snowflake: + datacenterId: 1 + workerId: 1 + application: + name: tall + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: 127.0.0.1 + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 +# password: '' + password: 'areowqr!@43ef' + port: 6379 + timeout: 1000ms +swagger: + enable: false +eureka: + instance: + # www.tall.wiki +# ip-address: 140.143.228.3 +# ip-address: 81.70.54.64 + ip-address: 192.144.182.42 + +gatewayUrl: https://www.tall.wiki/gateway/ +notGatewayUrl: https://www.tall.wiki/ +smsCode: 1 +wx: + prefixUrl: https://www.tall.wiki/wxconfigurer-api/ +file: + path: /home/cloud/tall/uploads/ + domain: https://www.tall.wiki/gateway/tall/v1.0/ + imgDomain: https://www.tall.wiki/gateway/tall/v1.0/uploads \ No newline at end of file diff --git a/ocr/src/main/resources/application-prodapi.yml b/ocr/src/main/resources/application-prodapi.yml new file mode 100644 index 00000000..c0e64083 --- /dev/null +++ b/ocr/src/main/resources/application-prodapi.yml @@ -0,0 +1,44 @@ +server: + port: 7031 + servlet: + context-path: /v1.0 +spring: + snowflake: + datacenterId: 3 + workerId: 3 + application: + name: tall + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: www.tall.wiki + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: www.tall.wiki + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: 'areowqr!@43ef' + port: 6379 + timeout: 1000ms +swagger: + enable: false +eureka: + instance: + ip-address: 129.28.149.79 + +gatewayUrl: https://www.tall.wiki/gateway/ +notGatewayUrl: https://www.tall.wiki/ +smsCode: 1 +wx: + prefixUrl: https://www.tall.wiki/wxconfigurer-api/ +file: + path: /home/cloud/tall/uploads/ + domain: https://www.tall.wiki/gateway/tall/v1.0/ + imgDomain: https://www.tall.wiki/gateway/tall/v1.0/uploads \ No newline at end of file diff --git a/ocr/src/main/resources/application-prodsd.yml b/ocr/src/main/resources/application-prodsd.yml new file mode 100644 index 00000000..0e72ae87 --- /dev/null +++ b/ocr/src/main/resources/application-prodsd.yml @@ -0,0 +1,44 @@ +server: + port: 7031 + servlet: + context-path: /v1.0 +spring: + snowflake: + datacenterId: 2 + workerId: 2 + application: + name: tall + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: www.tall.wiki + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: www.tall.wiki + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: 'areowqr!@43ef' + port: 6379 + timeout: 1000ms +swagger: + enable: false +eureka: + instance: + ip-address: 81.70.54.64 + +gatewayUrl: https://www.tall.wiki/gateway/ +notGatewayUrl: https://www.tall.wiki/ +smsCode: 1 +wx: + prefixUrl: https://www.tall.wiki/wxconfigurer-api/ +file: + path: /home/cloud/tall/uploads/ + domain: https://www.tall.wiki/gateway/tall/v1.0/ + imgDomain: https://www.tall.wiki/gateway/tall/v1.0/uploads \ No newline at end of file diff --git a/ocr/src/main/resources/application-test.yml b/ocr/src/main/resources/application-test.yml new file mode 100644 index 00000000..de3527c1 --- /dev/null +++ b/ocr/src/main/resources/application-test.yml @@ -0,0 +1,51 @@ +server: + port: 7030 + servlet: + context-path: /v1.0 +spring: + snowflake: + datacenterId: 1 + workerId: 1 + application: + name: tall + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: 127.0.0.1 +# host: api.ccsens.com + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true +eureka: + instance: + ip-address: 192.168.0.99 +# ip-address: 49.233.89.188 +#gatewayUrl: http://192.168.0.99/gateway/ +#notGatewayUrl: http://192.168.0.99/ +gatewayUrl: https://test.tall.wiki/gateway/ +notGatewayUrl: https://test.tall.wiki/ +smsCode: 0 +wx: + prefixUrl: https://www.tall.wiki/wxconfigurer-api/ +file: + path: /home/cloud/tall/uploads/ + domain: https://test.tall.wiki/gateway/tall/v1.0/ + imgDomain: https://test.tall.wiki/gateway/tall/v1.0/uploads + +#file: +# domain: http://192.168.0.99/gateway/tall/v1.0/ +# imgDomain: http://192.168.0.99/gateway/tall/v1.0/uploads \ No newline at end of file diff --git a/ocr/src/main/resources/application.yml b/ocr/src/main/resources/application.yml new file mode 100644 index 00000000..b5408a3a --- /dev/null +++ b/ocr/src/main/resources/application.yml @@ -0,0 +1,5 @@ +spring: + profiles: + active: dev + include: util-dev,common + diff --git a/ocr/src/main/resources/banner.txt b/ocr/src/main/resources/banner.txt new file mode 100644 index 00000000..759c9b00 --- /dev/null +++ b/ocr/src/main/resources/banner.txt @@ -0,0 +1,21 @@ +// _ooOoo_ +// o8888888o +// 88" . "88 +// (| -_- |) +// O\ = /O +// ____/`---'\____ +// . ' \\| |// `. +// / \\||| : |||// \ +// / _||||| -:- |||||- \ +// | | \\\ - /// | | +// | \_| ''\---/'' | | +// \ .-\__ `-` ___/-. / +// ___`. .' /--.--\ `. . __ +// ."" '< `.___\_<|>_/___.' >'"". +// | | : `- \`.;`\ _ /`;.`/ - ` : | | +// \ \ `-. \_ __\ /__ _/ .-` / / +// ======`-.____`-.___\_____/___.-`____.-'====== +// `=---=' +// +// ............................................. +// 佛祖保佑 永无BUG \ No newline at end of file diff --git a/ocr/src/main/resources/logback-spring.xml b/ocr/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..f3348e34 --- /dev/null +++ b/ocr/src/main/resources/logback-spring.xml @@ -0,0 +1,196 @@ + + + + + + + + + + logback + + + + + + + + + + + + + + + + + info + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + + + ${log.path}/log_debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/log_info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/log_warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + + ${log.path}/log_error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ocr/src/test/java/com/ccsens/orc/test/OrcTest.java b/ocr/src/test/java/com/ccsens/orc/test/OrcTest.java new file mode 100644 index 00000000..053a9eff --- /dev/null +++ b/ocr/src/test/java/com/ccsens/orc/test/OrcTest.java @@ -0,0 +1,44 @@ +package com.ccsens.orc.test; + +import org.junit.Test; +import org.opencv.core.Core; +import org.opencv.core.CvType; +import org.opencv.core.Mat; +import org.opencv.core.Size; +import org.opencv.imgcodecs.Imgcodecs; +import org.opencv.imgproc.Imgproc; + +/** + * @description: + * @author: whj + * @time: 2021/3/17 17:45 + */ +public class OrcTest { + + @Test + public void test01(){ + // 加载资源 + System.loadLibrary(Core.NATIVE_LIBRARY_NAME); + + //创建3px*3px的8UC1(8个位的无符号(8U)单通道(C1)整数) +// Mat hello = Mat.eye(3,3, CvType.CV_8UC1); +// System.out.println(hello.dump()); + //加载图片 +// Mat mat = Imgcodecs.imread("D:\\img\\0df7f58ea9d3a61019596094eb35003.png"); + // 加载图片并灰度图像 + Mat mat = Imgcodecs.imread("D:\\img\\0df7f58ea9d3a61019596094eb35003.png", Imgcodecs.IMREAD_GRAYSCALE); +// System.out.println(mat.width() + "*" + mat.height() + "," + mat.type()); + System.out.println(mat); + // 输出图片 +// Imgcodecs.imwrite("D:\\img\\1.png", mat); + // 截取图像 + Mat submat = mat.submat(50, 300, 60, 250); +// Imgcodecs.imwrite("D:\\img\\1.png", submat); + // 模糊图片 模糊子图片后,父模块也跟着模糊了 + Imgproc.blur(submat, submat, new Size(25.0,25.0)); + System.out.println(submat); + Imgcodecs.imwrite("D:\\img\\blur.png", mat); + + + } +} diff --git a/pom.xml b/pom.xml index 625987e1..3a1adf27 100644 --- a/pom.xml +++ b/pom.xml @@ -20,6 +20,7 @@ tcm + ocr