Add traditional image handling lib.

This commit is contained in:
Calvin 2021-06-28 00:33:02 +08:00
parent d6b4088140
commit f1eec080b0
31 changed files with 592 additions and 0 deletions

46
image_sdk/README.md Normal file
View File

@ -0,0 +1,46 @@
# 图像预处理SDK
在OCR文字识别的时候我们得到的图像一般情况下都不是正的多少都会有一定的倾斜。
所以需要将图片转正。并且图片有可能是透视视角拍摄,需要重新矫正。
### SDK功能
-图像转正
-图像二值化,灰度化,去燥等经典算法。
### 完善中的功能:
-完善透视矫正
-完善文字方向检测算法,判断转正后的图片角度,以便进一步旋转图片使得文字水平。
## 运行例子
1. 首先下载例子代码
```bash
git clone https://github.com/mymagicpower/AIAS.git
```
2. 导入examples项目到IDE中
```
cd image_sdk
```
3. 运行成功后,命令行应该看到下面的信息:
```text
319.0 , 865.0
319.0 , 113.0
785.0 , 113.0
785.0 , 865.0
startLeft = 319
startUp = 113
width = 467
height = 753
```
输出图片效果如下:
![ocr_result](https://djl-model.oss-cn-hongkong.aliyuncs.com/AIAS/image_sdk/images/rotation.png)
### 帮助
[点击下载SDK](https://djl-model.oss-cn-hongkong.aliyuncs.com/jars/aais-image-lib-0.1.0.jar).
添加依赖lib - aais-image-lib-0.1.0.jar
![lib](https://djl-model.oss-cn-hongkong.aliyuncs.com/AIAS/image_sdk/images/lib.png)
## QQ群
![Screenshot](https://djl-model.oss-cn-hongkong.aliyuncs.com/AIAS/OCR/OCR_QQ.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

BIN
image_sdk/doc/img/lib.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

188
image_sdk/image_sdk.iml Normal file
View File

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="CheckStyle-IDEA-Module">
<option name="configuration">
<map />
</option>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
<orderEntry type="library" name="Maven: commons-cli:commons-cli:1.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.12.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.12.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.logging.log4j:log4j-core:2.12.1" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:javacv-platform:1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:javacv:1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:javacpp:1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flycapture:2.13.3.31-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libdc1394:2.2.6-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect:0.5.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect2:0.2.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense:1.12.4-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense2:2.29.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:videoinput:0.200-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas-platform:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-arm:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-arm64:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-x86:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:android-x86_64:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:ios-arm64:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:ios-x86_64:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-x86:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-x86_64:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-armhf:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-arm64:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:linux-ppc64le:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:macosx-x86_64:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:windows-x86:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:openblas:windows-x86_64:0.3.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv-platform:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:android-arm:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:android-arm64:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:android-x86:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:android-x86_64:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:ios-arm64:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:ios-x86_64:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:linux-x86:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:linux-x86_64:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:linux-armhf:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:linux-arm64:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:linux-ppc64le:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:macosx-x86_64:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:windows-x86:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:opencv:windows-x86_64:4.1.2-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg-platform:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:android-arm:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:android-arm64:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:android-x86:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:android-x86_64:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:linux-x86:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:linux-x86_64:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:linux-armhf:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:linux-arm64:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:linux-ppc64le:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:macosx-x86_64:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:windows-x86:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:ffmpeg:windows-x86_64:4.2.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flycapture-platform:2.13.3.31-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flycapture:linux-x86:2.13.3.31-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flycapture:linux-x86_64:2.13.3.31-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flycapture:linux-armhf:2.13.3.31-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flycapture:linux-arm64:2.13.3.31-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flycapture:windows-x86:2.13.3.31-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flycapture:windows-x86_64:2.13.3.31-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libdc1394-platform:2.2.6-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libdc1394:linux-x86:2.2.6-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libdc1394:linux-x86_64:2.2.6-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libdc1394:linux-armhf:2.2.6-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libdc1394:linux-arm64:2.2.6-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libdc1394:linux-ppc64le:2.2.6-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libdc1394:macosx-x86_64:2.2.6-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libdc1394:windows-x86:2.2.6-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libdc1394:windows-x86_64:2.2.6-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect-platform:0.5.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect:linux-x86:0.5.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect:linux-x86_64:0.5.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect:linux-armhf:0.5.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect:linux-arm64:0.5.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect:linux-ppc64le:0.5.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect:macosx-x86_64:0.5.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect:windows-x86:0.5.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect:windows-x86_64:0.5.7-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect2-platform:0.2.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect2:linux-x86:0.2.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect2:linux-x86_64:0.2.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect2:macosx-x86_64:0.2.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:libfreenect2:windows-x86_64:0.2.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense-platform:1.12.4-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense:linux-x86:1.12.4-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense:linux-x86_64:1.12.4-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense:macosx-x86_64:1.12.4-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense:windows-x86:1.12.4-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense:windows-x86_64:1.12.4-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense2-platform:2.29.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense2:linux-x86:2.29.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense2:linux-x86_64:2.29.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense2:macosx-x86_64:2.29.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense2:windows-x86:2.29.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:librealsense2:windows-x86_64:2.29.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:videoinput-platform:0.200-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:videoinput:windows-x86:0.200-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:videoinput:windows-x86_64:0.200-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus-platform:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:android-arm:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:android-arm64:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:android-x86:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:android-x86_64:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:linux-x86:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:linux-x86_64:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:linux-armhf:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:linux-arm64:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:linux-ppc64le:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:macosx-x86_64:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:windows-x86:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:artoolkitplus:windows-x86_64:2.3.1-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark-platform:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:android-arm:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:android-arm64:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:android-x86:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:android-x86_64:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:linux-x86:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:linux-x86_64:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:linux-armhf:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:linux-arm64:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:linux-ppc64le:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:macosx-x86_64:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:windows-x86:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:flandmark:windows-x86_64:1.07-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica-platform:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:android-arm:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:android-arm64:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:android-x86:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:android-x86_64:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:linux-x86:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:linux-x86_64:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:linux-armhf:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:linux-arm64:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:linux-ppc64le:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:macosx-x86_64:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:windows-x86:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:leptonica:windows-x86_64:1.78.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract-platform:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:android-arm:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:android-arm64:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:android-x86:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:android-x86_64:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:linux-x86:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:linux-x86_64:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:linux-armhf:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:linux-arm64:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:linux-ppc64le:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:macosx-x86_64:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:windows-x86:4.1.0-1.5.2" level="project" />
<orderEntry type="library" name="Maven: org.bytedeco:tesseract:windows-x86_64:4.1.0-1.5.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.18" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.13.1" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="aais-image-lib-0.1.0" level="project" />
</component>
</module>

Binary file not shown.

88
image_sdk/pom.xml Normal file
View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>calvin</groupId>
<artifactId>image-sdk</artifactId>
<version>0.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
<version>3.8.1</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,45 @@
package me.calvin.example;
import me.calvin.opencv.utils.BinaryUtils;
import me.calvin.opencv.utils.GeneralUtils;
import me.calvin.opencv.utils.GrayUtils;
import org.bytedeco.opencv.opencv_core.Mat;
import org.junit.Test;
public class TestBinaryUtils {
@Test
/**
* 测试opencv自带的二值化
*/
public void testBinaryNative(){
String imgPath = "src/test/resources/1.png";
String destPath = "build/output/binary/";
Mat src = GeneralUtils.matFactory(imgPath);
src = GrayUtils.grayColByAdapThreshold(src);
src = BinaryUtils.binaryNative(src);
GeneralUtils.saveImg(src , destPath + "binaryNative.png");
}
@Test
/**
* 测试自定义二值化
*/
public void testBinaryzation(){
String imgPath = "src/test/resources/1.png";
String destPath = "build/output/binary/";
Mat src = GeneralUtils.matFactory(imgPath);
src = GrayUtils.grayColByAdapThreshold(src);
src = BinaryUtils.binaryzation(src);
GeneralUtils.saveImg(src , destPath + "binaryzation.png");
}
}

View File

@ -0,0 +1,95 @@
package me.calvin.example;
import me.calvin.opencv.utils.GeneralUtils;
import me.calvin.opencv.utils.GrayUtils;
import org.bytedeco.opencv.opencv_core.Mat;
import org.junit.Test;
/**
* 测试灰度化
*/
public class TestGrayUtils {
@Test
/**
* 测试opencv自带的灰度化方法
*/
public void testGrayNative(){
String imgPath = "src/test/resources/1.png";
String destPath = "build/output/gray/";
Mat src = GeneralUtils.matFactory(imgPath);
src = GrayUtils.grayNative(src);
GeneralUtils.saveImg(src , destPath + "grayNative.png");
}
@Test
/**
* 测试细粒度灰度化方法
* 均值灰度化减噪
*/
public void testGrayColByMidle() {
String imgPath = "src/test/resources/1.png";
String destPath = "build/output/gray/";
Mat src = GeneralUtils.matFactory(imgPath);
src = GrayUtils.grayColByMidle(src);
GeneralUtils.saveImg(src , destPath + "grayRowByMidle.png");
}
@Test
/**
* 测试细粒度灰度化方法
* k值灰度化减噪
*/
public void testGrayColByKLargest() {
String imgPath = "src/test/resources/1.png";
String destPath = "build/output/gray/";
Mat src = GeneralUtils.matFactory(imgPath);
src = GrayUtils.grayColByKLargest(src);
GeneralUtils.saveImg(src , destPath + "grayRowByKLargest.png");
}
@Test
/**
* 测试细粒度灰度化方法
* 局部自适应阀值灰度化减噪
*/
public void testGrayColByPartAdapThreshold() {
String imgPath = "src/test/resources/1.png";
String destPath = "build/output/gray/";
Mat src = GeneralUtils.matFactory(imgPath);
src = GrayUtils.grayColByPartAdapThreshold(src);
GeneralUtils.saveImg(src , destPath + "grayColByPartAdapThreshold.png");
}
@Test
/**
* 测试细粒度灰度化方法
* 全局自适应阀值灰度化减噪
*/
public void testGrayColByAdapThreshold() {
String imgPath = "src/test/resources/1.png";
String destPath = "build/output/gray/";
Mat src = GeneralUtils.matFactory(imgPath);
src = GrayUtils.grayColByAdapThreshold(src);
GeneralUtils.saveImg(src , destPath + "grayColByAdapThreshold.png");
}
}

View File

@ -0,0 +1,56 @@
package me.calvin.example;
import me.calvin.opencv.utils.BinaryUtils;
import me.calvin.opencv.utils.GeneralUtils;
import me.calvin.opencv.utils.GrayUtils;
import me.calvin.opencv.utils.NoiseUtils;
import org.bytedeco.opencv.opencv_core.Mat;
import org.junit.Test;
/**
* 测试降噪
*/
public class TestRemoveNoiseUtils {
@Test
/**
* 测试8邻域降噪
*/
public void testNativeRemoveNoise(){
String imgPath = "src/test/resources/1.png";
String destPath = "build/output/noise/";
Mat src = GeneralUtils.matFactory(imgPath);
src = GrayUtils.grayColByPartAdapThreshold(src);
src = BinaryUtils.binaryzation(src);
// 8邻域降噪
src = NoiseUtils.navieRemoveNoise(src , 1);
GeneralUtils.saveImg(src , destPath + "nativeRemoveNoise.png");
}
@Test
/**
* 连通域降噪
*/
public void testConnectedRemoveNoise(){
String imgPath = "src/test/resources/1.png";
String destPath = "build/output/noise/";
Mat src = GeneralUtils.matFactory(imgPath);
src = GrayUtils.grayColByPartAdapThreshold(src);
src = BinaryUtils.binaryzation(src);
// 连通域降噪
src = NoiseUtils.connectedRemoveNoise(src , 1);
GeneralUtils.saveImg(src , destPath + "connectedRemoveNoise.png");
}
}

View File

@ -0,0 +1,57 @@
package me.calvin.example;
import me.calvin.opencv.utils.*;
import org.bytedeco.opencv.opencv_core.*;
import java.io.IOException;
import java.util.stream.LongStream;
import static org.bytedeco.opencv.global.opencv_imgproc.*;
import static org.bytedeco.opencv.helper.opencv_imgcodecs.cvLoadImage;
public class TestRotation {
public static void main(String[] args) throws IOException {
IplImage marcel_ = cvLoadImage("src/test/resources/ticket_r2.png");
Mat marcel = new Mat(marcel_);
GeneralUtils.saveImg(marcel, "build/output/srcImg.jpg");
// 边缘检测
Mat cannyMat = GeneralUtils.canny(marcel);
GeneralUtils.saveImg(cannyMat, "build/output/canny.jpg");
// 获取所有轮廓
MatVector contours = ContourUtils.getContours(cannyMat);
Mat resultImage = cannyMat.clone();
LongStream.range(0, contours.size())
.mapToObj(contours::get)
.forEach(
contour -> {
Mat points = new Mat();
approxPolyDP(contour, points, arcLength(contour, true) * 0.02, true);
drawContours(resultImage, new MatVector(points), -1, Scalar.BLUE);
});
GeneralUtils.saveImg(resultImage, "build/output/contours.jpg");
// 获取最大外接矩形
RotatedRect rect = RectUtils.getMaxRect(contours);
Mat rectMat = marcel.clone();
Scalar scalar = new Scalar(255, 0, 0, 1);
Rect r = rect.boundingRect();
rectMat = DrawUtils.drawRect(rectMat, r, scalar);
GeneralUtils.saveImg(rectMat, "build/output/maxRect.jpg");
// 旋转矩形
Mat rotatedImg = RotationUtils.rotation(cannyMat, rect);
GeneralUtils.saveImg(rotatedImg, "build/output/rotatedImg.jpg");
Mat nativeRotatedImg = RotationUtils.rotation(marcel, rect);
GeneralUtils.saveImg(nativeRotatedImg, "build/output/nativeRotatedImg.jpg");
// 裁剪矩形
Mat cutMat = RectUtils.cutRect(rotatedImg, nativeRotatedImg);
GeneralUtils.saveImg(cutMat, "build/output/cutRect.jpg");
}
}

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout
pattern="[%-5level] - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info" additivity="false">
<AppenderRef ref="console"/>
</Root>
<Logger name="me.calvin" level="${sys:me.calvin.logging.level:-info}" additivity="false">
<AppenderRef ref="console"/>
</Logger>
</Loggers>
</Configuration>

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB