Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Belvire
otb
Commits
5e861a2d
Commit
5e861a2d
authored
9 years ago
by
Jordi Inglada
Browse files
Options
Downloads
Patches
Plain Diff
ENH: tidy up CvRTreesWrapper and add comments
parent
5f7e2735
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Modules/Learning/Supervised/include/otbCvRTreesWrapper.h
+19
-4
19 additions, 4 deletions
Modules/Learning/Supervised/include/otbCvRTreesWrapper.h
with
19 additions
and
4 deletions
Modules/Learning/Supervised/include/otbCvRTreesWrapper.h
+
19
−
4
View file @
5e861a2d
...
...
@@ -20,13 +20,29 @@
#include
"otbOpenCVUtils.h"
#include
<vector>
#include
<algorithm>
namespace
otb
{
/** \class CvRTreesWrapper
* \brief Wrapper for OpenCV Random Trees
*
* \ingroup OTBSupervised
*/
class
CV_EXPORTS_W
CvRTreesWrapper
:
public
CvRTrees
{
public:
CvRTreesWrapper
(){};
virtual
~
CvRTreesWrapper
(){};
/** Predict the confidence of the classifcation by computing the
difference in votes between the first and second most voted classes.
This measure is preferred to the proportion of votes of the majority
class, since it provides information about the conflict between the
most likely classes.
*/
float
predict_confidence
(
const
cv
::
Mat
&
sample
,
const
cv
::
Mat
&
missing
=
cv
::
Mat
())
const
...
...
@@ -39,16 +55,15 @@ public:
CV_Assert
(
0
<=
class_idx
&&
class_idx
<
nclasses
);
++
classVotes
[
class_idx
];
}
// We only sort the 2 greatest elements
std
::
nth_element
(
classVotes
.
begin
(),
classVotes
.
begin
()
+
1
,
classVotes
.
end
(),
std
::
greater
<>
());
unsigned
int
maxVotes
=
classVotes
[
0
];
unsigned
int
secondVotes
=
classVotes
[
1
];
float
confidence
=
static_cast
<
float
>
(
maxVotes
-
secondVotes
)
/
ntrees
;
float
confidence
=
static_cast
<
float
>
(
classVotes
[
0
]
-
classVotes
[
1
])
/
ntrees
;
return
confidence
;
};
};
}
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment