Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
imgproc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈皓
imgproc
Commits
cca6919c
Commit
cca6919c
authored
Nov 26, 2023
by
陈皓
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
89139b59
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
34 additions
and
64 deletions
+34
-64
imgproc-server/src/main/java/com/zq/imgproc/controller/ApiController.java
+2
-2
imgproc-server/src/main/java/com/zq/imgproc/server/ImgProcService.java
+11
-5
imgproc-server/src/main/java/com/zq/imgproc/utils/DemoUtil.java
+2
-2
imgproc-server/src/main/java/com/zq/imgproc/utils/TestUtil.java
+3
-3
imgproc-server/src/main/java/com/zq/imgproc/vo/DetectionResVo3.java
+0
-45
imgproc-server/src/main/java/com/zq/imgproc/vo/DetectionVO.java
+10
-6
imgproc-server/src/main/java/com/zq/imgproc/vo/ImgVO.java
+1
-1
imgproc-server/src/main/resources/application.yml
+5
-0
No files found.
imgproc-server/src/main/java/com/zq/imgproc/controller/ApiController.java
View file @
cca6919c
...
@@ -7,7 +7,7 @@ import cn.hutool.json.JSONObject;
...
@@ -7,7 +7,7 @@ import cn.hutool.json.JSONObject;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.zq.imgproc.server.ImgProcService
;
import
com.zq.imgproc.server.ImgProcService
;
import
com.zq.imgproc.utils.*
;
import
com.zq.imgproc.utils.*
;
import
com.zq.imgproc.vo.Detection
ResVo3
;
import
com.zq.imgproc.vo.Detection
VO
;
import
com.zq.imgproc.vo.OptimizationReq
;
import
com.zq.imgproc.vo.OptimizationReq
;
import
com.zq.imgproc.vo.OptimizationVO
;
import
com.zq.imgproc.vo.OptimizationVO
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -53,7 +53,7 @@ public class ApiController {
...
@@ -53,7 +53,7 @@ public class ApiController {
@ApiOperation
(
"图片检测"
)
@ApiOperation
(
"图片检测"
)
@PostMapping
(
"/detection"
)
@PostMapping
(
"/detection"
)
public
ResultVo
<
Detection
ResVo3
>
detection
(
@RequestBody
OptimizationReq
req
)
throws
Exception
{
public
ResultVo
<
Detection
VO
>
detection
(
@RequestBody
OptimizationReq
req
)
throws
Exception
{
AssertUtils
.
hasText
(
req
.
getFileContent
(),
"缺少文件内容"
);
AssertUtils
.
hasText
(
req
.
getFileContent
(),
"缺少文件内容"
);
AssertUtils
.
hasText
(
req
.
getFilename
(),
"缺少文件名"
);
AssertUtils
.
hasText
(
req
.
getFilename
(),
"缺少文件名"
);
return
ResultVo
.
success
(
service
.
detection2
(
req
));
return
ResultVo
.
success
(
service
.
detection2
(
req
));
...
...
imgproc-server/src/main/java/com/zq/imgproc/server/ImgProcService.java
View file @
cca6919c
...
@@ -66,7 +66,7 @@ public class ImgProcService {
...
@@ -66,7 +66,7 @@ public class ImgProcService {
public
List
<
ImgVO
>
detection
(
List
<
ImgVO
>
pathList
)
throws
Exception
{
public
List
<
ImgVO
>
detection
(
List
<
ImgVO
>
pathList
)
throws
Exception
{
List
<
ImgVO
>
res
=
new
ArrayList
<>(
pathList
.
size
());
List
<
ImgVO
>
res
=
new
ArrayList
<>(
pathList
.
size
());
for
(
ImgVO
one
:
pathList
)
{
for
(
ImgVO
one
:
pathList
)
{
Detection
ResVo2
vo
=
new
DetectionResVo2
();
Detection
VO
vo
=
new
DetectionVO
();
String
path
=
one
.
getUrl
();
String
path
=
one
.
getUrl
();
Mat
image
=
Imgcodecs
.
imread
(
path
);
Mat
image
=
Imgcodecs
.
imread
(
path
);
// 检测图片的分辨率
// 检测图片的分辨率
...
@@ -83,6 +83,9 @@ public class ImgProcService {
...
@@ -83,6 +83,9 @@ public class ImgProcService {
vo
.
setAngle
(
getAngle
(
image
));
vo
.
setAngle
(
getAngle
(
image
));
// 检测图片的黑边
// 检测图片的黑边
vo
.
setBlack
(
ImageUtil
.
blackDetection
(
image
));
vo
.
setBlack
(
ImageUtil
.
blackDetection
(
image
));
// 图片弯曲检测
BendResult
bendResult
=
BendUtil
.
getBendResult
(
path
);
vo
.
setBend
(
bendResult
.
getConfidence
());
one
.
setDetectionRes
(
vo
);
one
.
setDetectionRes
(
vo
);
res
.
add
(
one
);
res
.
add
(
one
);
}
}
...
@@ -108,7 +111,7 @@ public class ImgProcService {
...
@@ -108,7 +111,7 @@ public class ImgProcService {
return
res
;
return
res
;
}
}
public
Detection
ResVo3
detection2
(
OptimizationReq
req
)
throws
Exception
{
public
Detection
VO
detection2
(
OptimizationReq
req
)
throws
Exception
{
// 1. 临时保存图片
// 1. 临时保存图片
String
ext
=
FileUtil
.
extName
(
req
.
getFilename
());
String
ext
=
FileUtil
.
extName
(
req
.
getFilename
());
String
yyyyMMdd
=
new
SimpleDateFormat
(
"/yyyyMM/dd/"
).
format
(
new
Date
());
String
yyyyMMdd
=
new
SimpleDateFormat
(
"/yyyyMM/dd/"
).
format
(
new
Date
());
...
@@ -121,7 +124,7 @@ public class ImgProcService {
...
@@ -121,7 +124,7 @@ public class ImgProcService {
ImageIO
.
write
(
bufferedImage
,
"jpg"
,
new
File
(
filePath
));
ImageIO
.
write
(
bufferedImage
,
"jpg"
,
new
File
(
filePath
));
}
}
Detection
ResVo3
res
=
new
DetectionResVo3
();
Detection
VO
res
=
new
DetectionVO
();
Mat
image
=
Imgcodecs
.
imread
(
filePath
);
Mat
image
=
Imgcodecs
.
imread
(
filePath
);
// 检测图片的分辨率
// 检测图片的分辨率
res
.
setWidthResolution
(
image
.
width
());
res
.
setWidthResolution
(
image
.
width
());
...
@@ -136,6 +139,9 @@ public class ImgProcService {
...
@@ -136,6 +139,9 @@ public class ImgProcService {
res
.
setAngle
(
Deskew
.
getDeskewAngle
(
image
));
res
.
setAngle
(
Deskew
.
getDeskewAngle
(
image
));
// 检测图片的黑边
// 检测图片的黑边
res
.
setBlack
(
ImageUtil
.
blackDetection
(
image
));
res
.
setBlack
(
ImageUtil
.
blackDetection
(
image
));
// 图片弯曲检测
BendResult
bendResult
=
BendUtil
.
getBendResult
(
filePath
);
res
.
setBend
(
bendResult
.
getConfidence
());
image
.
release
();
image
.
release
();
FileUtil
.
del
(
filePath
);
FileUtil
.
del
(
filePath
);
return
res
;
return
res
;
...
@@ -700,7 +706,7 @@ public class ImgProcService {
...
@@ -700,7 +706,7 @@ public class ImgProcService {
}
}
public
ResponseEntity
<
Resource
>
getDetection
(
List
<
ImgVO
>
pathList
)
throws
Exception
{
public
ResponseEntity
<
Resource
>
getDetection
(
List
<
ImgVO
>
pathList
)
throws
Exception
{
if
(
pathList
==
null
||
pathList
.
size
()
==
0
)
{
if
(
pathList
==
null
||
pathList
.
isEmpty
()
)
{
return
ResponseEntity
.
badRequest
().
build
();
return
ResponseEntity
.
badRequest
().
build
();
}
}
pathList
=
detection
(
pathList
);
pathList
=
detection
(
pathList
);
...
@@ -724,7 +730,7 @@ public class ImgProcService {
...
@@ -724,7 +730,7 @@ public class ImgProcService {
private
List
<
DetectionDTO
>
getData
(
List
<
ImgVO
>
pathList
)
{
private
List
<
DetectionDTO
>
getData
(
List
<
ImgVO
>
pathList
)
{
List
<
DetectionDTO
>
dtos
=
new
ArrayList
<>(
pathList
.
size
());
List
<
DetectionDTO
>
dtos
=
new
ArrayList
<>(
pathList
.
size
());
for
(
ImgVO
imgVO
:
pathList
)
{
for
(
ImgVO
imgVO
:
pathList
)
{
Detection
ResVo2
detectionRes
=
imgVO
.
getDetectionRes
();
Detection
VO
detectionRes
=
imgVO
.
getDetectionRes
();
DetectionDTO
dto
=
new
DetectionDTO
();
DetectionDTO
dto
=
new
DetectionDTO
();
dto
.
setFilename
(
imgVO
.
getFileName
());
dto
.
setFilename
(
imgVO
.
getFileName
());
dto
.
setResolution
(
detectionRes
.
getWidthResolution
()
+
" x "
+
detectionRes
.
getHeightResolution
());
dto
.
setResolution
(
detectionRes
.
getWidthResolution
()
+
" x "
+
detectionRes
.
getHeightResolution
());
...
...
imgproc-server/src/main/java/com/zq/imgproc/utils/DemoUtil.java
View file @
cca6919c
...
@@ -7,7 +7,7 @@ import cn.hutool.http.HttpResponse;
...
@@ -7,7 +7,7 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.zq.imgproc.vo.Detection
ResVo3
;
import
com.zq.imgproc.vo.Detection
VO
;
import
com.zq.imgproc.vo.OptimizationReq
;
import
com.zq.imgproc.vo.OptimizationReq
;
import
com.zq.imgproc.vo.OptimizationVO
;
import
com.zq.imgproc.vo.OptimizationVO
;
...
@@ -34,7 +34,7 @@ public class DemoUtil {
...
@@ -34,7 +34,7 @@ public class DemoUtil {
System
.
out
.
println
(
System
.
currentTimeMillis
()
-
start
);
System
.
out
.
println
(
System
.
currentTimeMillis
()
-
start
);
String
res
=
response
.
body
();
String
res
=
response
.
body
();
JSONObject
object
=
JSONUtil
.
parseObj
(
res
);
JSONObject
object
=
JSONUtil
.
parseObj
(
res
);
Detection
ResVo3
detectionRes
=
object
.
get
(
"data"
,
DetectionResVo3
.
class
);
Detection
VO
detectionRes
=
object
.
get
(
"data"
,
DetectionVO
.
class
);
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
detectionRes
));
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
detectionRes
));
}
}
}
}
...
...
imgproc-server/src/main/java/com/zq/imgproc/utils/TestUtil.java
View file @
cca6919c
...
@@ -6,7 +6,7 @@ import com.drew.imaging.ImageMetadataReader;
...
@@ -6,7 +6,7 @@ import com.drew.imaging.ImageMetadataReader;
import
com.drew.metadata.Directory
;
import
com.drew.metadata.Directory
;
import
com.drew.metadata.Metadata
;
import
com.drew.metadata.Metadata
;
import
com.drew.metadata.Tag
;
import
com.drew.metadata.Tag
;
import
com.zq.imgproc.vo.Detection
ResVo3
;
import
com.zq.imgproc.vo.Detection
VO
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.imaging.ImageInfo
;
import
org.apache.commons.imaging.ImageInfo
;
import
org.apache.commons.imaging.Imaging
;
import
org.apache.commons.imaging.Imaging
;
...
@@ -65,8 +65,8 @@ public class TestUtil {
...
@@ -65,8 +65,8 @@ public class TestUtil {
}
}
}
}
public
static
Detection
ResVo3
detection
(
String
src
)
throws
Exception
{
public
static
Detection
VO
detection
(
String
src
)
throws
Exception
{
Detection
ResVo3
res
=
new
DetectionResVo3
();
Detection
VO
res
=
new
DetectionVO
();
Mat
image
=
Imgcodecs
.
imread
(
src
);
Mat
image
=
Imgcodecs
.
imread
(
src
);
// 检测图片的分辨率
// 检测图片的分辨率
res
.
setWidthResolution
(
image
.
width
());
res
.
setWidthResolution
(
image
.
width
());
...
...
imgproc-server/src/main/java/com/zq/imgproc/vo/DetectionResVo3.java
deleted
100644 → 0
View file @
89139b59
package
com
.
zq
.
imgproc
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* <p>
*
* </p>
*
* @author yww
* @since 2023/4/21
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public
class
DetectionResVo3
{
@ApiModelProperty
(
"图片的水平分辨率"
)
private
Integer
widthResolution
;
@ApiModelProperty
(
"图片的垂直分辨率"
)
private
Integer
heightResolution
;
@ApiModelProperty
(
"图片的DPI"
)
private
Integer
dpi
;
@ApiModelProperty
(
"图片平均亮度值"
)
private
double
brightness
;
@ApiModelProperty
(
"图片的清晰度指标,值越大越清晰"
)
private
double
clarity
;
@ApiModelProperty
(
"图片的倾斜角度"
)
private
double
angle
;
@ApiModelProperty
(
"图片的黑边检测,true表示可能存在黑边,false表示不存在黑边"
)
private
Boolean
black
;
}
imgproc-server/src/main/java/com/zq/imgproc/vo/Detection
ResVo2
.java
→
imgproc-server/src/main/java/com/zq/imgproc/vo/Detection
VO
.java
View file @
cca6919c
...
@@ -2,21 +2,23 @@ package com.zq.imgproc.vo;
...
@@ -2,21 +2,23 @@ package com.zq.imgproc.vo;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
/**
/**
* <p>
* <p>
*
图片返回结果封装类(带指标)
*
检测结果
* </
p
>
* </
P
>
*
*
* @author chenhao
* @author chenhao
* @since 2023/
3/10 16:48
* @since 2023/
11/26
*/
*/
@Data
@Builder
@NoArgsConstructor
@NoArgsConstructor
@AllArgsConstructor
@AllArgsConstructor
@Data
public
class
DetectionVO
{
public
class
DetectionResVo2
{
@ApiModelProperty
(
"图片的水平分辨率"
)
@ApiModelProperty
(
"图片的水平分辨率"
)
private
Integer
widthResolution
;
private
Integer
widthResolution
;
...
@@ -36,8 +38,10 @@ public class DetectionResVo2 {
...
@@ -36,8 +38,10 @@ public class DetectionResVo2 {
@ApiModelProperty
(
"图片的倾斜角度"
)
@ApiModelProperty
(
"图片的倾斜角度"
)
private
double
angle
;
private
double
angle
;
@ApiModelProperty
(
"图片弯曲检测置信度"
)
private
double
bend
;
@ApiModelProperty
(
"图片的黑边检测,true表示可能存在黑边,false表示不存在黑边"
)
@ApiModelProperty
(
"图片的黑边检测,true表示可能存在黑边,false表示不存在黑边"
)
private
Boolean
black
;
private
Boolean
black
;
}
}
imgproc-server/src/main/java/com/zq/imgproc/vo/ImgVO.java
View file @
cca6919c
...
@@ -25,6 +25,6 @@ public class ImgVO {
...
@@ -25,6 +25,6 @@ public class ImgVO {
String
url
;
String
url
;
Detection
ResVo2
detectionRes
;
Detection
VO
detectionRes
;
}
}
imgproc-server/src/main/resources/application.yml
View file @
cca6919c
...
@@ -24,6 +24,11 @@ imgconfig:
...
@@ -24,6 +24,11 @@ imgconfig:
deskewpy
:
/opt/tianjin/lib/correct.py
deskewpy
:
/opt/tianjin/lib/correct.py
#imgconfig:
#imgconfig:
# opencv: /opt/tianjin/lib/opencv_java460.so
# deskew: /opt/tianjin/lib/Deskew/Bin/deskew
# deskewpy: /opt/tianjin/lib/correct.py
#imgconfig:
# opencv: D:/project/imgproc/lib/opencv_java460.dll
# opencv: D:/project/imgproc/lib/opencv_java460.dll
# deskew: C:/Users/11419/Desktop/Deskew/Bin/deskew.exe
# deskew: C:/Users/11419/Desktop/Deskew/Bin/deskew.exe
# deskewpy: D:/project/imgproc/lib/correct.py
# deskewpy: D:/project/imgproc/lib/correct.py
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment