diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9c495be --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 divenswu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..2a926ac --- /dev/null +++ b/README.md @@ -0,0 +1,91 @@ +## 人脸搜索M:N + +* 最全车牌识别算法,支持14种中文车牌类型。 + +* 项目使用纯Java开发,免去使用Python带来的服务不稳定性。 + +* 项目模型来源: +* 欢迎大家贡献代码,如果你觉得项目还不错,请给个star。 + +### 项目简介 + +* 项目使用组件 + +    1、spring boot + +    2、[onnx](https://github.com/onnx/onnx) + +* 深度学习模型 + +    1、[Chinese_license_plate_detection_recognition](https://github.com/we0091234/Chinese_license_plate_detection_recognition) + + +### 项目文档 + +* 在线文档:[文档-1.0.0](scripts/docs/doc-1.0.0.md) + +* swagger文档:启动项目且开启swagger,访问:host:port/doc.html, 如 http://127.0.0.1:8080/doc.html + +### 搜索客户端 + +* Java依赖,未发布到中央仓库,需要自行编译发布到私有仓库 +``` + + com.visual.open.anpr + open-anpr-client + 1.0.0 + +``` +* 其他语言依赖 + +   使用restful接口:[文档-1.0.0](scripts/docs/doc-1.0.0.md) + + +### 项目部署 + +* docker部署 +``` +1、直接docker部署项目: +docker run -d --name "open-anpr" -p 56790:8080 divenswu/open-anpr:1.0.0 + +2、若想禁用swagger: +docker run -d --name "open-anpr" -p 56790:8080 -e VISUAL_SWAGGER_ENABLE=false divenswu/open-anpr:1.0.0 + +3、若想挂载日志目录到本地: +docker run -d --name "open-anpr" -p 56790:8080 -v open-anpr/logs:/app/open-anpr/logs divenswu/open-anpr:1.0.0 + +4、服务访问: + swagger借口文档: http://127.0.0.1:56790/doc.html +``` + +* 项目编译,并打包为docker镜像 +``` +1、java版本最低为:1.8;安装maven编译工具。安装docker。 +2、克隆项目 + git clone https://gitee.com/open-visual/open-anpr.git +3、项目打包 + cd open-anpr && sh scripts/docker_build.sh +``` + +* 部署参数 + +| 参数 | 描述 | 默认值 | 可选值 | +|------------------------|--------------:| :----: |------------| +| VISUAL_SWAGGER_ENABLE | 是否开启swagger | true | true/false | + + +### 项目演示 + +* 1.0.0 测试用例:open-anpr-test[测试用例-PlateRecognitionExample](https://gitee.com/open-visual/open-anpr/blob/master/open-anpr-test/src/main/java/com/visual/open/anpr/exps/PlateRecognitionExample.java) + +* ![输入图片说明](scripts%2Fimages%2Fvalidate-1.0.0.jpg) + +### 交流群 + +* 微信交流群 + + 关注微信公众号回复:微信群 + +* 微信公众号:关注一下,是对我最大的支持 + +![微信公众号](scripts/images/%E5%85%AC%E4%BC%97%E5%8F%B7-%E5%BE%AE%E4%BF%A1.jpg) diff --git a/open-anpr-core/src/test/java/com/visual/open/anpr/core/models/TorchPlateDetectionTest.java b/open-anpr-core/src/test/java/com/visual/open/anpr/core/models/TorchPlateDetectionTest.java index 33d6a4f..6b7b490 100644 --- a/open-anpr-core/src/test/java/com/visual/open/anpr/core/models/TorchPlateDetectionTest.java +++ b/open-anpr-core/src/test/java/com/visual/open/anpr/core/models/TorchPlateDetectionTest.java @@ -12,7 +12,7 @@ public class TorchPlateDetectionTest { public static void main(String[] args) { TorchPlateDetection torchPlateDetection = new TorchPlateDetection("open-anpr-core/src/main/resources/models/plate_detect.onnx", 1); - String imagePath = "open-anpr-core/src/test/resources/images"; + String imagePath = "open-anpr-core/src/test/resources/images/image001.jpg"; ImageMat imageMat = ImageMat.fromImage(imagePath); List plateInfos = torchPlateDetection.inference(imageMat, 0.3f,0.5f, new HashMap<>()); System.out.println(plateInfos); diff --git a/open-anpr-test/src/main/java/com/visual/open/anpr/exps/PlateRecognitionExample.java b/open-anpr-test/src/main/java/com/visual/open/anpr/exps/PlateRecognitionExample.java index 5fe8f91..1b3502a 100755 --- a/open-anpr-test/src/main/java/com/visual/open/anpr/exps/PlateRecognitionExample.java +++ b/open-anpr-test/src/main/java/com/visual/open/anpr/exps/PlateRecognitionExample.java @@ -15,9 +15,9 @@ public class PlateRecognitionExample { static{ nu.pattern.OpenCV.loadShared(); } //本地开发模式 - public static String serverHost = "http://127.0.0.1:8080"; +// public static String serverHost = "http://127.0.0.1:8080"; //docker部署模式 - //public static String serverHost = "http://127.0.0.1:56790"; + public static String serverHost = "http://172.16.36.228:56790"; //远程测试服务 //public static String serverHost = "http://open-anpr.diven.nat300.top"; @@ -27,6 +27,7 @@ public class PlateRecognitionExample { public static void recognition() { String searchPath = "open-anpr-test/src/main/resources/image"; File [] files = Objects.requireNonNull(new File(searchPath).listFiles()); +// for(int u=0; u<=1000; u++) for(int i=0; i< files.length-1; i++){ File imageA = files[i]; String imageBase64 = Base64Util.encode(imageA.getAbsolutePath()); diff --git a/scripts/docs/doc-1.0.0.md b/scripts/docs/doc-1.0.0.md new file mode 100644 index 0000000..4a8f6ee --- /dev/null +++ b/scripts/docs/doc-1.0.0.md @@ -0,0 +1,200 @@ +# 车牌识别服务API + + +**简介**:车牌识别服务API + + +**HOST**:http://127.0.0.1:8080 + + +**联系人**: + + +**Version**:1.0.0 + + +**接口路径**:/v3/api-docs?group=1.0.0 + + +[TOC] + + + + + + +# 01、车牌识别服务 + + +## 1、车牌识别 + + +**接口地址**:`/visual/plate/recognition` + + +**请求方式**:`POST` + + +**请求数据类型**:`application/x-www-form-urlencoded,application/json` + + +**响应数据类型**:`*/*` + + +**接口描述**: + + +**请求示例**: + + +```javascript +{ + "image": "", + "limit": 0 +} +``` + + +**请求参数**: + + +| 参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 | schema | +| -------- | -------- | ----- | -------- | -------- | ------ | +|plateInfoReqVo|车牌识别参数|body|true|PlateInfoReqVo|PlateInfoReqVo| +|  image|图像Base64编码值||true|string|| +|  limit|最大搜索条数:默认5||false|integer(int32)|| + + +**响应状态**: + + +| 状态码 | 说明 | schema | +| -------- | -------- | ----- | +|200|OK|ResponseInfo«List«PlateInfoRepVo»»| +|201|Created|| +|401|Unauthorized|| +|403|Forbidden|| +|404|Not Found|| + + +**响应参数**: + + +| 参数名称 | 参数说明 | 类型 | schema | +| -------- | -------- | ----- |----- | +|code|返回代码|integer(int32)|integer(int32)| +|data|数据信息|array|PlateInfoRepVo| +|  location|车牌位置信息|PlateLocation|PlateLocation| +|    leftBottom|左下角坐标|LocationPoint|LocationPoint| +|      x|坐标X的值|integer|| +|      y|坐标Y的值|integer|| +|    leftTop|左上角坐标值|LocationPoint|LocationPoint| +|      x|坐标X的值|integer|| +|      y|坐标Y的值|integer|| +|    rightBottom|右下角坐标|LocationPoint|LocationPoint| +|      x|坐标X的值|integer|| +|      y|坐标Y的值|integer|| +|    rightTop|右上角坐标|LocationPoint|LocationPoint| +|      x|坐标X的值|integer|| +|      y|坐标Y的值|integer|| +|  recognition|车牌识别信息|RecognitionInfo|RecognitionInfo| +|    layout|车牌布局,单排还是双排,可用值:DOUBLE,SINGLE,UNKNOWN|string|| +|    plateColor|车牌的颜色信息,可用值:BLACK,BLUE,GREEN,UNKNOWN,WHITE,YELLOW|string|| +|    plateNo|车牌文本信息|string|| +|  score|车牌置信分数:[0,100]|number(float)|| +|message|返回信息|string|| + + +**响应示例**: +```javascript +{ + "code": 0, + "data": [ + { + "location": { + "leftBottom": { + "x": 0, + "y": 0 + }, + "leftTop": { + "x": 0, + "y": 0 + }, + "rightBottom": { + "x": 0, + "y": 0 + }, + "rightTop": { + "x": 0, + "y": 0 + } + }, + "recognition": { + "layout": "", + "plateColor": "", + "plateNo": "" + }, + "score": 0 + } + ], + "message": "" +} +``` + + +# 02、健康检测服务 + + +## 1、健康检查 + + +**接口地址**:`/common/health/check` + + +**请求方式**:`GET` + + +**请求数据类型**:`application/x-www-form-urlencoded` + + +**响应数据类型**:`*/*` + + +**接口描述**: + + +**请求参数**: + + +暂无 + + +**响应状态**: + + +| 状态码 | 说明 | schema | +| -------- | -------- | ----- | +|200|OK|ResponseInfo«string»| +|401|Unauthorized|| +|403|Forbidden|| +|404|Not Found|| + + +**响应参数**: + + +| 参数名称 | 参数说明 | 类型 | schema | +| -------- | -------- | ----- |----- | +|code|返回代码|integer(int32)|integer(int32)| +|data|数据信息|string|| +|message|返回信息|string|| + + +**响应示例**: +```javascript +{ + "code": 0, + "data": "", + "message": "" +} +``` \ No newline at end of file diff --git a/scripts/images/validate-1.0.0.jpg b/scripts/images/validate-1.0.0.jpg new file mode 100644 index 0000000..3fbac22 Binary files /dev/null and b/scripts/images/validate-1.0.0.jpg differ diff --git a/scripts/images/公众号-微信.jpg b/scripts/images/公众号-微信.jpg new file mode 100644 index 0000000..54dbe74 Binary files /dev/null and b/scripts/images/公众号-微信.jpg differ