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
dfaf75f5
Commit
dfaf75f5
authored
Sep 06, 2014
by
Dmitriy Anisimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moving algorithm type to param
parent
5f3ee657
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
11 deletions
+12
-11
ml.hpp
modules/ml/include/opencv2/ml.hpp
+4
-3
knearest.cpp
modules/ml/src/knearest.cpp
+7
-7
test_emknearestkmeans.cpp
modules/ml/test/test_emknearestkmeans.cpp
+1
-1
No files found.
modules/ml/include/opencv2/ml.hpp
View file @
dfaf75f5
...
...
@@ -230,8 +230,9 @@ public:
class
CV_EXPORTS_W_MAP
Params
{
public
:
Params
(
int
defaultK
=
10
,
bool
isclassifier_
=
true
,
int
Emax_
=
INT_MAX
);
Params
(
int
algorithmType_
=
BRUTE_FORCE
,
int
defaultK
=
10
,
bool
isclassifier_
=
true
,
int
Emax_
=
INT_MAX
);
CV_PROP_RW
int
algorithmType
;
CV_PROP_RW
int
defaultK
;
CV_PROP_RW
bool
isclassifier
;
CV_PROP_RW
int
Emax
;
// for implementation with KDTree
...
...
@@ -243,9 +244,9 @@ public:
OutputArray
neighborResponses
=
noArray
(),
OutputArray
dist
=
noArray
()
)
const
=
0
;
enum
{
DEFAULT
=
1
,
KDTREE
=
2
};
enum
{
BRUTE_FORCE
=
1
,
KDTREE
=
2
};
static
Ptr
<
KNearest
>
create
(
const
Params
&
params
=
Params
()
,
int
type
=
DEFAULT
);
static
Ptr
<
KNearest
>
create
(
const
Params
&
params
=
Params
());
};
/****************************************************************************************\
...
...
modules/ml/src/knearest.cpp
View file @
dfaf75f5
...
...
@@ -50,14 +50,14 @@
namespace
cv
{
namespace
ml
{
KNearest
::
Params
::
Params
(
int
k
,
bool
isclassifier_
,
int
Emax_
)
KNearest
::
Params
::
Params
(
int
algorithmType_
,
int
k
,
bool
isclassifier_
,
int
Emax_
)
:
algorithmType
(
algorithmType_
),
defaultK
(
k
),
isclassifier
(
isclassifier_
),
Emax
(
Emax_
)
{
defaultK
=
k
;
isclassifier
=
isclassifier_
;
Emax
=
Emax_
;
}
class
KNearestImpl
:
public
KNearest
{
public
:
...
...
@@ -497,9 +497,9 @@ public:
Params
params
;
};
Ptr
<
KNearest
>
KNearest
::
create
(
const
Params
&
p
,
int
type
)
Ptr
<
KNearest
>
KNearest
::
create
(
const
Params
&
p
)
{
if
(
KDTREE
==
t
ype
)
if
(
KDTREE
==
p
.
algorithmT
ype
)
{
return
makePtr
<
KNearestKDTreeImpl
>
(
p
);
}
...
...
modules/ml/test/test_emknearestkmeans.cpp
View file @
dfaf75f5
...
...
@@ -330,7 +330,7 @@ void CV_KNearestTest::run( int /*start_from*/ )
}
// KNearest KDTree implementation
Ptr
<
KNearest
>
knearestKdt
=
KNearest
::
create
(
ml
::
KNearest
::
Params
(
),
ml
::
KNearest
::
KDTREE
);
Ptr
<
KNearest
>
knearestKdt
=
KNearest
::
create
(
ml
::
KNearest
::
Params
(
ml
::
KNearest
::
KDTREE
)
);
knearestKdt
->
train
(
trainData
,
ml
::
ROW_SAMPLE
,
trainLabels
);
knearestKdt
->
findNearest
(
testData
,
4
,
bestLabels
);
if
(
!
calcErr
(
bestLabels
,
testLabels
,
sizes
,
err
,
true
)
)
...
...
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