Browse Source

init

master
diven 2 years ago
parent
commit
76bbe50fc7
  1. 21
      LICENSE
  2. 91
      README.md
  3. 2
      open-anpr-core/src/test/java/com/visual/open/anpr/core/models/TorchPlateDetectionTest.java
  4. 5
      open-anpr-test/src/main/java/com/visual/open/anpr/exps/PlateRecognitionExample.java
  5. 200
      scripts/docs/doc-1.0.0.md
  6. BIN
      scripts/images/validate-1.0.0.jpg
  7. BIN
      scripts/images/公众号-微信.jpg

21
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.

91
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依赖,未发布到中央仓库,需要自行编译发布到私有仓库
```
<dependency>
<groupId>com.visual.open.anpr</groupId>
<artifactId>open-anpr-client</artifactId>
<version>1.0.0</version>
</dependency>
```
* 其他语言依赖
&ensp; &ensp;使用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)

2
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) { public static void main(String[] args) {
TorchPlateDetection torchPlateDetection = new TorchPlateDetection("open-anpr-core/src/main/resources/models/plate_detect.onnx", 1); 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); ImageMat imageMat = ImageMat.fromImage(imagePath);
List<PlateInfo> plateInfos = torchPlateDetection.inference(imageMat, 0.3f,0.5f, new HashMap<>()); List<PlateInfo> plateInfos = torchPlateDetection.inference(imageMat, 0.3f,0.5f, new HashMap<>());
System.out.println(plateInfos); System.out.println(plateInfos);

5
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(); } 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部署模式 //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"; //public static String serverHost = "http://open-anpr.diven.nat300.top";
@ -27,6 +27,7 @@ public class PlateRecognitionExample {
public static void recognition() { public static void recognition() {
String searchPath = "open-anpr-test/src/main/resources/image"; String searchPath = "open-anpr-test/src/main/resources/image";
File [] files = Objects.requireNonNull(new File(searchPath).listFiles()); File [] files = Objects.requireNonNull(new File(searchPath).listFiles());
// for(int u=0; u<=1000; u++)
for(int i=0; i< files.length-1; i++){ for(int i=0; i< files.length-1; i++){
File imageA = files[i]; File imageA = files[i];
String imageBase64 = Base64Util.encode(imageA.getAbsolutePath()); String imageBase64 = Base64Util.encode(imageA.getAbsolutePath());

200
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|
|&emsp;&emsp;image|图像Base64编码值||true|string||
|&emsp;&emsp;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|
|&emsp;&emsp;location|车牌位置信息|PlateLocation|PlateLocation|
|&emsp;&emsp;&emsp;&emsp;leftBottom|左下角坐标|LocationPoint|LocationPoint|
|&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;x|坐标X的值|integer||
|&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;y|坐标Y的值|integer||
|&emsp;&emsp;&emsp;&emsp;leftTop|左上角坐标值|LocationPoint|LocationPoint|
|&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;x|坐标X的值|integer||
|&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;y|坐标Y的值|integer||
|&emsp;&emsp;&emsp;&emsp;rightBottom|右下角坐标|LocationPoint|LocationPoint|
|&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;x|坐标X的值|integer||
|&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;y|坐标Y的值|integer||
|&emsp;&emsp;&emsp;&emsp;rightTop|右上角坐标|LocationPoint|LocationPoint|
|&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;x|坐标X的值|integer||
|&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;y|坐标Y的值|integer||
|&emsp;&emsp;recognition|车牌识别信息|RecognitionInfo|RecognitionInfo|
|&emsp;&emsp;&emsp;&emsp;layout|车牌布局,单排还是双排,可用值:DOUBLE,SINGLE,UNKNOWN|string||
|&emsp;&emsp;&emsp;&emsp;plateColor|车牌的颜色信息,可用值:BLACK,BLUE,GREEN,UNKNOWN,WHITE,YELLOW|string||
|&emsp;&emsp;&emsp;&emsp;plateNo|车牌文本信息|string||
|&emsp;&emsp;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": ""
}
```

BIN
scripts/images/validate-1.0.0.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

BIN
scripts/images/公众号-微信.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Loading…
Cancel
Save