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
25575af6
Commit
25575af6
authored
Oct 13, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #808 from berak:text_fix_ocrhmm_memleak
parents
4f1bb945
c3c9723f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
+3
-7
ocr_hmm_decoder.cpp
modules/text/src/ocr_hmm_decoder.cpp
+3
-7
No files found.
modules/text/src/ocr_hmm_decoder.cpp
View file @
25575af6
...
...
@@ -935,7 +935,7 @@ public:
protected
:
void
normalizeAndZCA
(
Mat
&
patches
);
double
eval_feature
(
Mat
&
feature
,
double
*
prob_estimates
);
double
eval_feature
(
Mat
&
feature
,
vector
<
double
>&
prob_estimates
);
private
:
int
nr_class
;
// number of classes
...
...
@@ -1089,7 +1089,7 @@ void OCRHMMClassifierCNN::eval( InputArray _src, vector<int>& out_class, vector<
(
feature_max
.
at
<
double
>
(
0
,
k
)
-
feature_min
.
at
<
double
>
(
0
,
k
));
}
double
*
p
=
new
double
[
nr_class
]
;
vector
<
double
>
p
(
nr_class
,
0
)
;
double
predict_label
=
eval_feature
(
feature
,
p
);
//cout << " Prediction: " << vocabulary[predict_label] << " with probability " << p[0] << endl;
if
(
predict_label
<
0
)
...
...
@@ -1107,7 +1107,6 @@ void OCRHMMClassifierCNN::eval( InputArray _src, vector<int>& out_class, vector<
}
}
}
// normalize for contrast and apply ZCA whitening to a set of image patches
...
...
@@ -1157,11 +1156,8 @@ void OCRHMMClassifierCNN::normalizeAndZCA(Mat& patches)
}
double
OCRHMMClassifierCNN
::
eval_feature
(
Mat
&
feature
,
double
*
prob_estimates
)
double
OCRHMMClassifierCNN
::
eval_feature
(
Mat
&
feature
,
vector
<
double
>&
prob_estimates
)
{
for
(
int
i
=
0
;
i
<
nr_class
;
i
++
)
prob_estimates
[
i
]
=
0
;
for
(
int
idx
=
0
;
idx
<
nr_feature
;
idx
++
)
for
(
int
i
=
0
;
i
<
nr_class
;
i
++
)
prob_estimates
[
i
]
+=
weights
.
at
<
float
>
(
idx
,
i
)
*
feature
.
at
<
double
>
(
0
,
idx
);
//TODO use vectorized dot product
...
...
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