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
2cf16db6
Commit
2cf16db6
authored
Nov 11, 2013
by
Baichuan Su
Committed by
Ilya Lavrenov
Dec 04, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Macro to decide using ocl method or not.
parent
00300baa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
bagofwords_classification.cpp
samples/cpp/bagofwords_classification.cpp
+4
-3
points_classifier.cpp
samples/cpp/points_classifier.cpp
+5
-3
No files found.
samples/cpp/bagofwords_classification.cpp
View file @
2cf16db6
...
...
@@ -5,6 +5,7 @@
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/ml/ml.hpp"
#ifdef HAVE_OPENCV_OCL
#define _OCL_SVM_ 0 //select whether using ocl::svm method or not, default is not
#include "opencv2/ocl/ocl.hpp"
#endif
...
...
@@ -2377,7 +2378,7 @@ static void setSVMTrainAutoParams( CvParamGrid& c_grid, CvParamGrid& gamma_grid,
degree_grid
.
step
=
0
;
}
#if
def HAVE_OPENCV_OCL
#if
defined HAVE_OPENCV_OCL && _OCL_SVM_
static
void
trainSVMClassifier
(
cv
::
ocl
::
CvSVM_OCL
&
svm
,
const
SVMTrainParamsExt
&
svmParamsExt
,
const
string
&
objClassName
,
VocData
&
vocData
,
Ptr
<
BOWImgDescriptorExtractor
>&
bowExtractor
,
const
Ptr
<
FeatureDetector
>&
fdetector
,
const
string
&
resPath
)
...
...
@@ -2458,7 +2459,7 @@ static void trainSVMClassifier( CvSVM& svm, const SVMTrainParamsExt& svmParamsEx
}
}
#if
def HAVE_OPENCV_OCL
#if
defined HAVE_OPENCV_OCL && _OCL_SVM_
static
void
computeConfidences
(
cv
::
ocl
::
CvSVM_OCL
&
svm
,
const
string
&
objClassName
,
VocData
&
vocData
,
Ptr
<
BOWImgDescriptorExtractor
>&
bowExtractor
,
const
Ptr
<
FeatureDetector
>&
fdetector
,
const
string
&
resPath
)
...
...
@@ -2605,7 +2606,7 @@ int main(int argc, char** argv)
for
(
size_t
classIdx
=
0
;
classIdx
<
objClasses
.
size
();
++
classIdx
)
{
// Train a classifier on train dataset
#if
def HAVE_OPENCV_OCL
#if
defined HAVE_OPENCV_OCL && _OCL_SVM_
cv
::
ocl
::
CvSVM_OCL
svm
;
#else
CvSVM
svm
;
...
...
samples/cpp/points_classifier.cpp
View file @
2cf16db6
...
...
@@ -3,6 +3,8 @@
#include "opencv2/ml/ml.hpp"
#include "opencv2/highgui/highgui.hpp"
#ifdef HAVE_OPENCV_OCL
#define _OCL_KNN_ 0 // select whether using ocl::KNN method or not, default is not
#define _OCL_SVM_ 0 // select whether using ocl::svm method or not, default is not
#include "opencv2/ocl/ocl.hpp"
#endif
...
...
@@ -137,7 +139,7 @@ static void find_decision_boundary_KNN( int K )
prepare_train_data
(
trainSamples
,
trainClasses
);
// learn classifier
#if
def HAVE_OPENCV_OCL
#if
defined HAVE_OPENCV_OCL && _OCL_KNN_
cv
::
ocl
::
KNearestNeighbour
knnClassifier
;
Mat
temp
,
result
;
knnClassifier
.
train
(
trainSamples
,
trainClasses
,
temp
,
false
,
K
);
...
...
@@ -153,7 +155,7 @@ static void find_decision_boundary_KNN( int K )
{
testSample
.
at
<
float
>
(
0
)
=
(
float
)
x
;
testSample
.
at
<
float
>
(
1
)
=
(
float
)
y
;
#if
def HAVE_OPENCV_OCL
#if
defined HAVE_OPENCV_OCL && _OCL_KNN_
testSample_ocl
.
upload
(
testSample
);
knnClassifier
.
find_nearest
(
testSample_ocl
,
K
,
reslut_ocl
);
...
...
@@ -180,7 +182,7 @@ static void find_decision_boundary_SVM( CvSVMParams params )
prepare_train_data
(
trainSamples
,
trainClasses
);
// learn classifier
#if
def HAVE_OPENCV_OCL
#if
defined HAVE_OPENCV_OCL && _OCL_SVM_
cv
::
ocl
::
CvSVM_OCL
svmClassifier
(
trainSamples
,
trainClasses
,
Mat
(),
Mat
(),
params
);
#else
CvSVM
svmClassifier
(
trainSamples
,
trainClasses
,
Mat
(),
Mat
(),
params
);
...
...
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