Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
273
Issues
273
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
302d9e14
Commit
302d9e14
authored
Feb 16, 2017
by
Guillaume Pasero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: adapt CvRTreesWrapper to opencv3 (WIP)
parent
b69df7c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
Modules/Learning/Supervised/include/otbCvRTreesWrapper.h
Modules/Learning/Supervised/include/otbCvRTreesWrapper.h
+9
-1
Modules/Learning/Supervised/src/otbCvRTreesWrapper.cxx
Modules/Learning/Supervised/src/otbCvRTreesWrapper.cxx
+20
-1
No files found.
Modules/Learning/Supervised/include/otbCvRTreesWrapper.h
View file @
302d9e14
...
...
@@ -29,7 +29,10 @@ namespace otb
*
* \ingroup OTBSupervised
*/
class
OTBSupervised_EXPORT
CvRTreesWrapper
:
public
CvRTrees
class
OTBSupervised_EXPORT
CvRTreesWrapper
#ifndef OTB_OPENCV_3
:
public
CvRTrees
#endif
{
public:
typedef
std
::
vector
<
unsigned
int
>
VotesVectorType
;
...
...
@@ -57,6 +60,11 @@ public:
float
predict_margin
(
const
cv
::
Mat
&
sample
,
const
cv
::
Mat
&
missing
=
cv
::
Mat
())
const
;
private:
#ifdef OTB_OPENCV_3
cv
::
Ptr
<
cv
::
ml
::
RTrees
>
m_RTrees
;
#endif
};
}
...
...
Modules/Learning/Supervised/src/otbCvRTreesWrapper.cxx
View file @
302d9e14
...
...
@@ -22,7 +22,12 @@
namespace
otb
{
CvRTreesWrapper
::
CvRTreesWrapper
(){}
CvRTreesWrapper
::
CvRTreesWrapper
()
{
#ifdef OTB_OPENCV_3
m_RTrees
=
cv
::
ml
::
RTrees
::
create
();
#endif
}
CvRTreesWrapper
::~
CvRTreesWrapper
(){}
...
...
@@ -30,6 +35,9 @@ void CvRTreesWrapper::get_votes(const cv::Mat& sample,
const
cv
::
Mat
&
missing
,
CvRTreesWrapper
::
VotesVectorType
&
vote_count
)
const
{
#ifdef OTB_OPENCV_3
// TODO
#else
vote_count
.
resize
(
nclasses
);
for
(
int
k
=
0
;
k
<
ntrees
;
k
++
)
{
...
...
@@ -38,11 +46,16 @@ void CvRTreesWrapper::get_votes(const cv::Mat& sample,
CV_Assert
(
0
<=
class_idx
&&
class_idx
<
nclasses
);
++
vote_count
[
class_idx
];
}
#endif
}
float
CvRTreesWrapper
::
predict_margin
(
const
cv
::
Mat
&
sample
,
const
cv
::
Mat
&
missing
)
const
{
#ifdef OTB_OPENCV_3
// TODO
return
0.
;
#else
// Sanity check (division by ntrees later on)
if
(
ntrees
==
0
)
{
...
...
@@ -55,11 +68,16 @@ float CvRTreesWrapper::predict_margin(const cv::Mat& sample,
classVotes
.
end
(),
std
::
greater
<
unsigned
int
>
());
float
margin
=
static_cast
<
float
>
(
classVotes
[
0
]
-
classVotes
[
1
])
/
ntrees
;
return
margin
;
#endif
}
float
CvRTreesWrapper
::
predict_confidence
(
const
cv
::
Mat
&
sample
,
const
cv
::
Mat
&
missing
)
const
{
#ifdef OTB_OPENCV_3
// TODO
return
0.
;
#else
// Sanity check (division by ntrees later on)
if
(
ntrees
==
0
)
{
...
...
@@ -71,6 +89,7 @@ float CvRTreesWrapper::predict_confidence(const cv::Mat& sample,
classVotes
.
end
()));
float
confidence
=
static_cast
<
float
>
(
max_votes
)
/
ntrees
;
return
confidence
;
#endif
}
}
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