Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
caaf0bd4
Commit
caaf0bd4
authored
Jul 11, 2020
by
LDOUBLEV
Browse files
take crnnresizeImg place of crnnresizeNormImg
parent
d56bcc16
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
25 deletions
+4
-25
deploy/lite/crnn_process.cc
deploy/lite/crnn_process.cc
+2
-23
deploy/lite/crnn_process.h
deploy/lite/crnn_process.h
+1
-1
deploy/lite/ocr_db_crnn.cc
deploy/lite/ocr_db_crnn.cc
+1
-1
No files found.
deploy/lite/crnn_process.cc
View file @
caaf0bd4
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
const
std
::
vector
<
int
>
rec_image_shape
{
3
,
32
,
320
};
const
std
::
vector
<
int
>
rec_image_shape
{
3
,
32
,
320
};
cv
::
Mat
CrnnResize
Norm
Img
(
cv
::
Mat
img
,
float
wh_ratio
,
bool
is_norm
)
{
cv
::
Mat
CrnnResizeImg
(
cv
::
Mat
img
,
float
wh_ratio
)
{
int
imgC
,
imgH
,
imgW
;
int
imgC
,
imgH
,
imgW
;
imgC
=
rec_image_shape
[
0
];
imgC
=
rec_image_shape
[
0
];
imgW
=
rec_image_shape
[
2
];
imgW
=
rec_image_shape
[
2
];
...
@@ -37,28 +37,7 @@ cv::Mat CrnnResizeNormImg(cv::Mat img, float wh_ratio, bool is_norm) {
...
@@ -37,28 +37,7 @@ cv::Mat CrnnResizeNormImg(cv::Mat img, float wh_ratio, bool is_norm) {
cv
::
resize
(
img
,
resize_img
,
cv
::
Size
(
resize_w
,
imgH
),
0.
f
,
0.
f
,
cv
::
resize
(
img
,
resize_img
,
cv
::
Size
(
resize_w
,
imgH
),
0.
f
,
0.
f
,
cv
::
INTER_LINEAR
);
cv
::
INTER_LINEAR
);
if
(
!
is_norm
)
{
return
resize_img
;
return
resize_img
;
}
else
{
resize_img
.
convertTo
(
resize_img
,
CV_32FC3
,
1
/
255.
f
);
for
(
int
h
=
0
;
h
<
resize_img
.
rows
;
h
++
)
{
for
(
int
w
=
0
;
w
<
resize_img
.
cols
;
w
++
)
{
resize_img
.
at
<
cv
::
Vec3f
>
(
h
,
w
)[
0
]
=
(
resize_img
.
at
<
cv
::
Vec3f
>
(
h
,
w
)[
0
]
-
0.5
)
*
2
;
resize_img
.
at
<
cv
::
Vec3f
>
(
h
,
w
)[
1
]
=
(
resize_img
.
at
<
cv
::
Vec3f
>
(
h
,
w
)[
1
]
-
0.5
)
*
2
;
resize_img
.
at
<
cv
::
Vec3f
>
(
h
,
w
)[
2
]
=
(
resize_img
.
at
<
cv
::
Vec3f
>
(
h
,
w
)[
2
]
-
0.5
)
*
2
;
}
}
cv
::
Mat
dist
;
cv
::
copyMakeBorder
(
resize_img
,
dist
,
0
,
0
,
0
,
int
(
imgW
-
resize_w
),
cv
::
BORDER_CONSTANT
,
{
0
,
0
,
0
});
return
dist
;
}
}
}
std
::
vector
<
std
::
string
>
ReadDict
(
std
::
string
path
)
{
std
::
vector
<
std
::
string
>
ReadDict
(
std
::
string
path
)
{
...
...
deploy/lite/crnn_process.h
View file @
caaf0bd4
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc.hpp"
cv
::
Mat
CrnnResize
Norm
Img
(
cv
::
Mat
img
,
float
wh_ratio
,
bool
is_norm
);
cv
::
Mat
CrnnResizeImg
(
cv
::
Mat
img
,
float
wh_ratio
);
std
::
vector
<
std
::
string
>
ReadDict
(
std
::
string
path
);
std
::
vector
<
std
::
string
>
ReadDict
(
std
::
string
path
);
...
...
deploy/lite/ocr_db_crnn.cc
View file @
caaf0bd4
...
@@ -123,7 +123,7 @@ void RunRecModel(std::vector<std::vector<std::vector<int>>> boxes, cv::Mat img,
...
@@ -123,7 +123,7 @@ void RunRecModel(std::vector<std::vector<std::vector<int>>> boxes, cv::Mat img,
crop_img
=
GetRotateCropImage
(
srcimg
,
boxes
[
i
]);
crop_img
=
GetRotateCropImage
(
srcimg
,
boxes
[
i
]);
float
wh_ratio
=
float
(
crop_img
.
cols
)
/
float
(
crop_img
.
rows
);
float
wh_ratio
=
float
(
crop_img
.
cols
)
/
float
(
crop_img
.
rows
);
resize_img
=
CrnnResize
Norm
Img
(
crop_img
,
wh_ratio
,
false
);
resize_img
=
CrnnResizeImg
(
crop_img
,
wh_ratio
);
resize_img
.
convertTo
(
resize_img
,
CV_32FC3
,
1
/
255.
f
);
resize_img
.
convertTo
(
resize_img
,
CV_32FC3
,
1
/
255.
f
);
const
float
*
dimg
=
reinterpret_cast
<
const
float
*>
(
resize_img
.
data
);
const
float
*
dimg
=
reinterpret_cast
<
const
float
*>
(
resize_img
.
data
);
...
...
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