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
5aeeaa6f
Commit
5aeeaa6f
authored
11 years ago
by
Pierre-Emmanuel Viel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply to KMeansIndex KMeanspp the same modification as in HierarchicalClusteringIndex
parent
45e0e5f8
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
kmeans_index.h
modules/flann/include/opencv2/flann/kmeans_index.h
+9
-2
No files found.
modules/flann/include/opencv2/flann/kmeans_index.h
View file @
5aeeaa6f
...
...
@@ -211,6 +211,7 @@ public:
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
closestDistSq
[
i
]
=
distance_
(
dataset_
[
indices
[
i
]],
dataset_
[
indices
[
index
]],
dataset_
.
cols
);
closestDistSq
[
i
]
*=
closestDistSq
[
i
];
currentPot
+=
closestDistSq
[
i
];
}
...
...
@@ -236,7 +237,10 @@ public:
// Compute the new potential
double
newPot
=
0
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
newPot
+=
std
::
min
(
distance_
(
dataset_
[
indices
[
i
]],
dataset_
[
indices
[
index
]],
dataset_
.
cols
),
closestDistSq
[
i
]
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
DistanceType
dist
=
distance_
(
dataset_
[
indices
[
i
]],
dataset_
[
indices
[
index
]],
dataset_
.
cols
);
newPot
+=
std
::
min
(
dist
*
dist
,
closestDistSq
[
i
]
);
}
// Store the best result
if
((
bestNewPot
<
0
)
||
(
newPot
<
bestNewPot
))
{
...
...
@@ -248,7 +252,10 @@ public:
// Add the appropriate center
centers
[
centerCount
]
=
indices
[
bestNewIndex
];
currentPot
=
bestNewPot
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
closestDistSq
[
i
]
=
std
::
min
(
distance_
(
dataset_
[
indices
[
i
]],
dataset_
[
indices
[
bestNewIndex
]],
dataset_
.
cols
),
closestDistSq
[
i
]
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
DistanceType
dist
=
distance_
(
dataset_
[
indices
[
i
]],
dataset_
[
indices
[
bestNewIndex
]],
dataset_
.
cols
);
closestDistSq
[
i
]
=
std
::
min
(
dist
*
dist
,
closestDistSq
[
i
]
);
}
}
centers_length
=
centerCount
;
...
...
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