Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
a98d6b62
Commit
a98d6b62
authored
Jun 14, 2012
by
Alexander Mordvintsev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exposed parallelized SVM prediction to python (predict_all)
parent
e4d9d529
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
2 deletions
+9
-2
ml.hpp
modules/ml/include/opencv2/ml/ml.hpp
+2
-1
svm.cpp
modules/ml/src/svm.cpp
+6
-0
letter_recog.py
samples/python2/letter_recog.py
+1
-1
No files found.
modules/ml/include/opencv2/ml/ml.hpp
View file @
a98d6b62
...
...
@@ -488,7 +488,7 @@ public:
bool
balanced
=
false
);
virtual
float
predict
(
const
CvMat
*
sample
,
bool
returnDFVal
=
false
)
const
;
virtual
float
predict
(
const
CvMat
*
samples
,
CvMat
*
results
)
const
;
virtual
float
predict
(
const
CvMat
*
samples
,
C
V_OUT
C
vMat
*
results
)
const
;
#ifndef SWIG
CV_WRAP
CvSVM
(
const
cv
::
Mat
&
trainData
,
const
cv
::
Mat
&
responses
,
...
...
@@ -510,6 +510,7 @@ public:
CvParamGrid
degreeGrid
=
CvSVM
::
get_default_grid
(
CvSVM
::
DEGREE
),
bool
balanced
=
false
);
CV_WRAP
virtual
float
predict
(
const
cv
::
Mat
&
sample
,
bool
returnDFVal
=
false
)
const
;
CV_WRAP_AS
(
predict_all
)
virtual
void
predict
(
cv
::
InputArray
samples
,
cv
::
OutputArray
results
)
const
;
#endif
CV_WRAP
virtual
int
get_support_vector_count
()
const
;
...
...
modules/ml/src/svm.cpp
View file @
a98d6b62
...
...
@@ -2124,6 +2124,12 @@ float CvSVM::predict(const CvMat* samples, CV_OUT CvMat* results) const
return
result
;
}
void
CvSVM
::
predict
(
cv
::
InputArray
_samples
,
cv
::
OutputArray
_results
)
const
{
_results
.
create
(
_samples
.
size
().
height
,
1
,
CV_32F
);
CvMat
samples
=
_samples
.
getMat
(),
results
=
_results
.
getMat
();
predict
(
&
samples
,
&
results
);
}
CvSVM
::
CvSVM
(
const
Mat
&
_train_data
,
const
Mat
&
_responses
,
const
Mat
&
_var_idx
,
const
Mat
&
_sample_idx
,
CvSVMParams
_params
)
...
...
samples/python2/letter_recog.py
View file @
a98d6b62
...
...
@@ -88,7 +88,7 @@ class SVM(LetterStatModel):
self
.
model
.
train
(
samples
,
responses
,
params
=
params
)
def
predict
(
self
,
samples
):
return
np
.
float32
(
[
self
.
model
.
predict
(
s
)
for
s
in
samples
]
)
return
self
.
model
.
predict_all
(
samples
)
.
ravel
(
)
class
MLP
(
LetterStatModel
):
...
...
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