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
67da3f06
Commit
67da3f06
authored
Aug 14, 2014
by
lluis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds class OCRHMMDecoder API interface and implementation
parent
36a31161
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
1 deletion
+48
-1
ocr.hpp
modules/text/include/opencv2/text/ocr.hpp
+48
-1
ocr_hmm_decoder.cpp
modules/text/src/ocr_hmm_decoder.cpp
+0
-0
No files found.
modules/text/include/opencv2/text/ocr.hpp
View file @
67da3f06
...
...
@@ -52,7 +52,6 @@ namespace cv
namespace
text
{
enum
{
OCR_LEVEL_WORD
,
...
...
@@ -69,6 +68,8 @@ public:
int
component_level
=
0
)
=
0
;
};
/* OCR Tesseract */
class
CV_EXPORTS
OCRTesseract
:
public
BaseOCR
{
public
:
...
...
@@ -81,6 +82,52 @@ public:
};
/* OCR HMM Decoder */
enum
decoder_mode
{
OCR_DECODER_VITERBI
=
0
// Other algorithms may be added
};
class
CV_EXPORTS
OCRHMMDecoder
:
public
BaseOCR
{
public
:
//! callback with the character classifier is made a class. This way we hide the feature extractor and the classifier itself
class
CV_EXPORTS
ClassifierCallback
{
public
:
virtual
~
ClassifierCallback
()
{
}
//! The classifier must return a (ranked list of) class(es) id('s)
virtual
void
eval
(
InputArray
image
,
std
::
vector
<
int
>&
out_class
,
std
::
vector
<
double
>&
out_confidence
);
};
public
:
//! Decode a group of regions and output the most likely sequence of characters
virtual
void
run
(
Mat
&
image
,
std
::
string
&
output_text
,
std
::
vector
<
Rect
>*
component_rects
=
NULL
,
std
::
vector
<
std
::
string
>*
component_texts
=
NULL
,
std
::
vector
<
float
>*
component_confidences
=
NULL
,
int
component_level
=
0
);
static
Ptr
<
OCRHMMDecoder
>
create
(
const
Ptr
<
OCRHMMDecoder
::
ClassifierCallback
>
classifier
,
// The character classifier with built in feature extractor
const
std
::
string
&
vocabulary
,
// The language vocabulary (chars when ascii english text)
// size() must be equal to the number of classes
InputArray
transition_probabilities_table
,
// Table with transition probabilities between character pairs
// cols == rows == vocabulari.size()
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)
protected
:
Ptr
<
OCRHMMDecoder
::
ClassifierCallback
>
classifier
;
std
::
string
vocabulary
;
Mat
transition_p
;
Mat
emission_p
;
decoder_mode
mode
;
};
CV_EXPORTS
Ptr
<
OCRHMMDecoder
::
ClassifierCallback
>
loadOCRHMMClassifierNM
(
const
std
::
string
&
filename
);
}
}
#endif // _OPENCV_TEXT_OCR_HPP_
modules/text/src/ocr_hmm_decoder.cpp
0 → 100644
View file @
67da3f06
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