Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
e2f9c666
Commit
e2f9c666
authored
Aug 27, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #350 from lluisgomez:ocrbeamsearch_refactor
parents
3431d8ae
c3042c3f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
4 deletions
+10
-4
ocr.hpp
modules/text/include/opencv2/text/ocr.hpp
+4
-1
cropped_word_recognition.cpp
modules/text/samples/cropped_word_recognition.cpp
+6
-3
scenetext_word03.jpg
modules/text/samples/scenetext_word03.jpg
+0
-0
scenetext_word04.jpg
modules/text/samples/scenetext_word04.jpg
+0
-0
ocr_beamsearch_decoder.cpp
modules/text/src/ocr_beamsearch_decoder.cpp
+0
-0
No files found.
modules/text/include/opencv2/text/ocr.hpp
View file @
e2f9c666
...
...
@@ -338,6 +338,9 @@ public:
including 0 as start-sequence location.
*/
virtual
void
eval
(
InputArray
image
,
std
::
vector
<
std
::
vector
<
double
>
>&
recognition_probabilities
,
std
::
vector
<
int
>&
oversegmentation
);
int
getWindowSize
()
{
return
0
;}
int
getStepSize
()
{
return
0
;}
};
public
:
...
...
@@ -396,7 +399,7 @@ public:
InputArray
emission_probabilities_table
,
// Table with observation emission probabilities
// cols == rows == vocabulari.size()
decoder_mode
mode
=
OCR_DECODER_VITERBI
,
// HMM Decoding algorithm (only Viterbi for the moment)
int
beam_size
=
50
);
// Size of the beam in Beam Search algorithm
int
beam_size
=
50
0
);
// Size of the beam in Beam Search algorithm
protected
:
...
...
modules/text/samples/cropped_word_recognition.cpp
View file @
e2f9c666
...
...
@@ -39,12 +39,13 @@ int main(int argc, char* argv[])
string
vocabulary
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
;
// must have the same order as the clasifier output classes
vector
<
string
>
lexicon
;
// a list of words expected to be found on the input image
lexicon
.
push_back
(
string
(
"abb"
));
lexicon
.
push_back
(
string
(
"
patata
"
));
lexicon
.
push_back
(
string
(
"
riser
"
));
lexicon
.
push_back
(
string
(
"CHINA"
));
lexicon
.
push_back
(
string
(
"HERE"
));
lexicon
.
push_back
(
string
(
"President"
));
lexicon
.
push_back
(
string
(
"smash"
));
lexicon
.
push_back
(
string
(
"KUALA"
));
lexicon
.
push_back
(
string
(
"Produkt"
));
lexicon
.
push_back
(
string
(
"NINTENDO"
));
// Create tailored language model a small given lexicon
...
...
@@ -54,16 +55,18 @@ int main(int argc, char* argv[])
// An alternative would be to load the default generic language model
// (created from ispell 42869 english words list)
/*Mat transition_p;
string filename = "OCRHMM_transitions_table.xml";
// TODO use same order for voc
string filename = "OCRHMM_transitions_table.xml";
FileStorage fs(filename, FileStorage::READ);
fs["transition_probabilities"] >> transition_p;
fs.release();*/
Mat
emission_p
=
Mat
::
eye
(
62
,
62
,
CV_64FC1
);
// Notice we set here a beam size of 50. This is much faster than using the default value (500).
// 50 works well with our tiny lexicon example, but may not with larger dictionaries.
Ptr
<
OCRBeamSearchDecoder
>
ocr
=
OCRBeamSearchDecoder
::
create
(
loadOCRBeamSearchClassifierCNN
(
"OCRBeamSearch_CNN_model_data.xml.gz"
),
vocabulary
,
transition_p
,
emission_p
);
vocabulary
,
transition_p
,
emission_p
,
OCR_DECODER_VITERBI
,
50
);
double
t_r
=
(
double
)
getTickCount
();
string
output
;
...
...
modules/text/samples/scenetext_word03.jpg
0 → 100644
View file @
e2f9c666
17.1 KB
modules/text/samples/scenetext_word04.jpg
0 → 100644
View file @
e2f9c666
46.4 KB
modules/text/src/ocr_beamsearch_decoder.cpp
View file @
e2f9c666
This diff is collapsed.
Click to expand it.
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