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
3391caf4
Commit
3391caf4
authored
Jun 12, 2014
by
Vadim Pisarevsky
Committed by
OpenCV Buildbot
Jun 12, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2779 from pemmanuelviel:kmeansppSquareDist
parents
1f4ddbe5
ec99f96c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
dist.h
modules/flann/include/opencv2/flann/dist.h
+60
-0
No files found.
modules/flann/include/opencv2/flann/dist.h
View file @
3391caf4
...
@@ -872,6 +872,66 @@ typename Distance::ResultType ensureSquareDistance( typename Distance::ResultTyp
...
@@ -872,6 +872,66 @@ typename Distance::ResultType ensureSquareDistance( typename Distance::ResultTyp
return
dummy
(
dist
);
return
dummy
(
dist
);
}
}
/*
* ...and a template to ensure the user that he will process the normal distance,
* and not squared distance, without loosing processing time calling sqrt(ensureSquareDistance)
* that will result in doing actually sqrt(dist*dist) for L1 distance for instance.
*/
template
<
typename
Distance
,
typename
ElementType
>
struct
simpleDistance
{
typedef
typename
Distance
::
ResultType
ResultType
;
ResultType
operator
()(
ResultType
dist
)
{
return
dist
;
}
};
template
<
typename
ElementType
>
struct
simpleDistance
<
L2_Simple
<
ElementType
>
,
ElementType
>
{
typedef
typename
L2_Simple
<
ElementType
>::
ResultType
ResultType
;
ResultType
operator
()(
ResultType
dist
)
{
return
sqrt
(
dist
);
}
};
template
<
typename
ElementType
>
struct
simpleDistance
<
L2
<
ElementType
>
,
ElementType
>
{
typedef
typename
L2
<
ElementType
>::
ResultType
ResultType
;
ResultType
operator
()(
ResultType
dist
)
{
return
sqrt
(
dist
);
}
};
template
<
typename
ElementType
>
struct
simpleDistance
<
MinkowskiDistance
<
ElementType
>
,
ElementType
>
{
typedef
typename
MinkowskiDistance
<
ElementType
>::
ResultType
ResultType
;
ResultType
operator
()(
ResultType
dist
)
{
return
sqrt
(
dist
);
}
};
template
<
typename
ElementType
>
struct
simpleDistance
<
HellingerDistance
<
ElementType
>
,
ElementType
>
{
typedef
typename
HellingerDistance
<
ElementType
>::
ResultType
ResultType
;
ResultType
operator
()(
ResultType
dist
)
{
return
sqrt
(
dist
);
}
};
template
<
typename
ElementType
>
struct
simpleDistance
<
ChiSquareDistance
<
ElementType
>
,
ElementType
>
{
typedef
typename
ChiSquareDistance
<
ElementType
>::
ResultType
ResultType
;
ResultType
operator
()(
ResultType
dist
)
{
return
sqrt
(
dist
);
}
};
template
<
typename
Distance
>
typename
Distance
::
ResultType
ensureSimpleDistance
(
typename
Distance
::
ResultType
dist
)
{
typedef
typename
Distance
::
ElementType
ElementType
;
simpleDistance
<
Distance
,
ElementType
>
dummy
;
return
dummy
(
dist
);
}
}
}
#endif //OPENCV_FLANN_DIST_H_
#endif //OPENCV_FLANN_DIST_H_
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