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
98ea0779
Commit
98ea0779
authored
Feb 01, 2021
by
WenmuZhou
Browse files
add det_db_use_dilate config
parent
49d5dcca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
deploy/lite/config.txt
deploy/lite/config.txt
+2
-1
deploy/lite/ocr_db_crnn.cc
deploy/lite/ocr_db_crnn.cc
+10
-6
No files found.
deploy/lite/config.txt
View file @
98ea0779
...
@@ -2,4 +2,5 @@ max_side_len 960
...
@@ -2,4 +2,5 @@ max_side_len 960
det_db_thresh 0.3
det_db_thresh 0.3
det_db_box_thresh 0.5
det_db_box_thresh 0.5
det_db_unclip_ratio 1.6
det_db_unclip_ratio 1.6
use_direction_classify 0
det_db_use_dilate 0
\ No newline at end of file
use_direction_classify 1
\ No newline at end of file
deploy/lite/ocr_db_crnn.cc
View file @
98ea0779
...
@@ -229,6 +229,7 @@ RunDetModel(std::shared_ptr<PaddlePredictor> predictor, cv::Mat img,
...
@@ -229,6 +229,7 @@ RunDetModel(std::shared_ptr<PaddlePredictor> predictor, cv::Mat img,
std
::
map
<
std
::
string
,
double
>
Config
)
{
std
::
map
<
std
::
string
,
double
>
Config
)
{
// Read img
// Read img
int
max_side_len
=
int
(
Config
[
"max_side_len"
]);
int
max_side_len
=
int
(
Config
[
"max_side_len"
]);
int
det_db_use_dilate
=
int
(
Config
[
"det_db_use_dilate"
]);
cv
::
Mat
srcimg
;
cv
::
Mat
srcimg
;
img
.
copyTo
(
srcimg
);
img
.
copyTo
(
srcimg
);
...
@@ -275,10 +276,14 @@ RunDetModel(std::shared_ptr<PaddlePredictor> predictor, cv::Mat img,
...
@@ -275,10 +276,14 @@ RunDetModel(std::shared_ptr<PaddlePredictor> predictor, cv::Mat img,
const
double
maxvalue
=
255
;
const
double
maxvalue
=
255
;
cv
::
Mat
bit_map
;
cv
::
Mat
bit_map
;
cv
::
threshold
(
cbuf_map
,
bit_map
,
threshold
,
maxvalue
,
cv
::
THRESH_BINARY
);
cv
::
threshold
(
cbuf_map
,
bit_map
,
threshold
,
maxvalue
,
cv
::
THRESH_BINARY
);
cv
::
Mat
dilation_map
;
if
(
det_db_use_dilate
==
1
)
{
cv
::
Mat
dila_ele
=
cv
::
getStructuringElement
(
cv
::
MORPH_RECT
,
cv
::
Size
(
2
,
2
));
cv
::
Mat
dilation_map
;
cv
::
dilate
(
bit_map
,
dilation_map
,
dila_ele
);
cv
::
Mat
dila_ele
=
auto
boxes
=
BoxesFromBitmap
(
pred_map
,
dilation_map
,
Config
);
cv
::
getStructuringElement
(
cv
::
MORPH_RECT
,
cv
::
Size
(
2
,
2
));
cv
::
dilate
(
bit_map
,
dilation_map
,
dila_ele
);
bit_map
=
dilation_map
;
}
auto
boxes
=
BoxesFromBitmap
(
pred_map
,
bit_map
,
Config
);
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>>>
filter_boxes
=
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>>>
filter_boxes
=
FilterTagDetRes
(
boxes
,
ratio_hw
[
0
],
ratio_hw
[
1
],
srcimg
);
FilterTagDetRes
(
boxes
,
ratio_hw
[
0
],
ratio_hw
[
1
],
srcimg
);
...
@@ -375,8 +380,7 @@ int main(int argc, char **argv) {
...
@@ -375,8 +380,7 @@ int main(int argc, char **argv) {
auto
charactor_dict
=
ReadDict
(
dict_path
);
auto
charactor_dict
=
ReadDict
(
dict_path
);
charactor_dict
.
insert
(
charactor_dict
.
begin
(),
"#"
);
// blank char for ctc
charactor_dict
.
insert
(
charactor_dict
.
begin
(),
"#"
);
// blank char for ctc
charactor_dict
.
push_back
(
" "
);
charactor_dict
.
push_back
(
" "
);
std:
cout
<<
charactor_dict
[
0
]
<<
" "
<<
charactor_dict
[
1
]
<<
std
::
endl
;
cv
::
Mat
srcimg
=
cv
::
imread
(
img_path
,
cv
::
IMREAD_COLOR
);
cv
::
Mat
srcimg
=
cv
::
imread
(
img_path
,
cv
::
IMREAD_COLOR
);
auto
boxes
=
RunDetModel
(
det_predictor
,
srcimg
,
Config
);
auto
boxes
=
RunDetModel
(
det_predictor
,
srcimg
,
Config
);
...
...
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