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
7da3c639
Commit
7da3c639
authored
Feb 22, 2017
by
Guillaume Pasero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: complete wrapping of CvRTreeWrapper
parent
381d42f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
7 deletions
+160
-7
Modules/Learning/Supervised/include/otbCvRTreesWrapper.h
Modules/Learning/Supervised/include/otbCvRTreesWrapper.h
+62
-3
Modules/Learning/Supervised/src/otbCvRTreesWrapper.cxx
Modules/Learning/Supervised/src/otbCvRTreesWrapper.cxx
+98
-4
No files found.
Modules/Learning/Supervised/include/otbCvRTreesWrapper.h
View file @
7da3c639
...
...
@@ -30,7 +30,9 @@ namespace otb
* \ingroup OTBSupervised
*/
class
OTBSupervised_EXPORT
CvRTreesWrapper
#ifndef OTB_OPENCV_3
#ifdef OTB_OPENCV_3
:
public
cv
::
ml
::
RTrees
#else
:
public
CvRTrees
#endif
{
...
...
@@ -61,10 +63,67 @@ public:
const
cv
::
Mat
&
missing
=
cv
::
Mat
())
const
;
private:
#ifdef OTB_OPENCV_3
cv
::
Ptr
<
cv
::
ml
::
RTrees
>
m_RTrees
;
#define OTB_CV_WRAP_PROPERTY(type,name) \
virtual type get##name() const; \
virtual void set##name(type val);
#define OTB_CV_WRAP_PROPERTY_REF(type,name) \
virtual type get##name() const; \
virtual void set##name(const type &val);
#define OTB_CV_WRAP_CSTREF_GET(type, name) \
virtual const type& get##name() const;
// TODO : wrap all method used
virtual
int
getVarCount
()
const
;
virtual
bool
isTrained
()
const
;
virtual
bool
isClassifier
()
const
;
OTB_CV_WRAP_PROPERTY
(
int
,
MaxCategories
)
OTB_CV_WRAP_PROPERTY
(
int
,
MaxDepth
)
OTB_CV_WRAP_PROPERTY
(
int
,
MinSampleCount
)
OTB_CV_WRAP_PROPERTY
(
bool
,
UseSurrogates
)
OTB_CV_WRAP_PROPERTY
(
int
,
CVFolds
)
OTB_CV_WRAP_PROPERTY
(
bool
,
Use1SERule
)
OTB_CV_WRAP_PROPERTY
(
bool
,
TruncatePrunedTree
)
OTB_CV_WRAP_PROPERTY
(
float
,
RegressionAccuracy
)
OTB_CV_WRAP_PROPERTY
(
bool
,
CalculateVarImportance
)
OTB_CV_WRAP_PROPERTY
(
int
,
ActiveVarCount
)
OTB_CV_WRAP_PROPERTY_REF
(
cv
::
Mat
,
Priors
)
OTB_CV_WRAP_PROPERTY_REF
(
cv
::
TermCriteria
,
TermCriteria
)
OTB_CV_WRAP_CSTREF_GET
(
std
::
vector
<
int
>
,
Roots
)
OTB_CV_WRAP_CSTREF_GET
(
std
::
vector
<
cv
::
ml
::
DTrees
::
Node
>
,
Nodes
)
OTB_CV_WRAP_CSTREF_GET
(
std
::
vector
<
cv
::
ml
::
DTrees
::
Split
>
,
Splits
)
OTB_CV_WRAP_CSTREF_GET
(
std
::
vector
<
int
>
,
Subsets
)
virtual
cv
::
Mat
getVarImportance
()
const
;
virtual
cv
::
String
getDefaultName
()
const
;
virtual
void
read
(
const
cv
::
FileNode
&
fn
);
virtual
void
save
(
const
cv
::
String
&
filename
)
const
;
virtual
bool
train
(
cv
::
InputArray
samples
,
int
layout
,
cv
::
InputArray
responses
);
virtual
bool
train
(
const
cv
::
Ptr
<
cv
::
ml
::
TrainData
>&
trainData
,
int
flags
=
0
);
virtual
float
predict
(
cv
::
InputArray
samples
,
cv
::
OutputArray
results
=
cv
::
noArray
(),
int
flags
=
0
)
const
;
static
cv
::
Ptr
<
CvRTreesWrapper
>
create
();
#undef OTB_CV_WRAP_PROPERTY
#undef OTB_CV_WRAP_PROPERTY_REF
#undef OTB_CV_WRAP_CSTREF_GET
#endif
private:
cv
::
Ptr
<
cv
::
ml
::
RTrees
>
m_Impl
;
};
}
...
...
Modules/Learning/Supervised/src/otbCvRTreesWrapper.cxx
View file @
7da3c639
...
...
@@ -27,15 +27,12 @@ void dont_delete_me(void *){}
CvRTreesWrapper
::
CvRTreesWrapper
()
{
#ifdef OTB_OPENCV_3
m_
RTrees
=
cv
::
Ptr
<
cv
::
ml
::
RTrees
>
((
cv
::
ml
::
RTrees
::
create
()).
get
(),
dont_delete_me
).
get
();
m_
Impl
=
cv
::
ml
::
RTrees
::
create
();
#endif
}
CvRTreesWrapper
::~
CvRTreesWrapper
()
{
#ifdef OTB_OPENCV_3
delete
m_RTrees
;
#endif
}
void
CvRTreesWrapper
::
get_votes
(
const
cv
::
Mat
&
sample
,
...
...
@@ -99,4 +96,101 @@ float CvRTreesWrapper::predict_confidence(const cv::Mat& sample,
#endif
}
#ifdef OTB_OPENCV_3
#define OTB_CV_WRAP_IMPL(type,name) \
type CvRTreesWrapper::get##name() const \
{ return m_Impl->get##name(); } \
void CvRTreesWrapper::set##name(type val) \
{ m_Impl->set##name(val); }
#define OTB_CV_WRAP_IMPL_REF(type,name) \
type CvRTreesWrapper::get##name() const \
{ return m_Impl->get##name(); } \
void CvRTreesWrapper::set##name(const type &val) \
{ m_Impl->set##name(val); }
#define OTB_CV_WRAP_IMPL_CSTREF_GET(type, name) \
const type& CvRTreesWrapper::get##name() const \
{ return m_Impl->get##name(); }
// TODO : wrap all method used
OTB_CV_WRAP_IMPL
(
int
,
MaxCategories
)
OTB_CV_WRAP_IMPL
(
int
,
MaxDepth
)
OTB_CV_WRAP_IMPL
(
int
,
MinSampleCount
)
OTB_CV_WRAP_IMPL
(
bool
,
UseSurrogates
)
OTB_CV_WRAP_IMPL
(
int
,
CVFolds
)
OTB_CV_WRAP_IMPL
(
bool
,
Use1SERule
)
OTB_CV_WRAP_IMPL
(
bool
,
TruncatePrunedTree
)
OTB_CV_WRAP_IMPL
(
float
,
RegressionAccuracy
)
OTB_CV_WRAP_IMPL
(
bool
,
CalculateVarImportance
)
OTB_CV_WRAP_IMPL
(
int
,
ActiveVarCount
)
OTB_CV_WRAP_IMPL_REF
(
cv
::
Mat
,
Priors
)
OTB_CV_WRAP_IMPL_REF
(
cv
::
TermCriteria
,
TermCriteria
)
OTB_CV_WRAP_IMPL_CSTREF_GET
(
std
::
vector
<
int
>
,
Roots
)
OTB_CV_WRAP_IMPL_CSTREF_GET
(
std
::
vector
<
cv
::
ml
::
DTrees
::
Node
>
,
Nodes
)
OTB_CV_WRAP_IMPL_CSTREF_GET
(
std
::
vector
<
cv
::
ml
::
DTrees
::
Split
>
,
Splits
)
OTB_CV_WRAP_IMPL_CSTREF_GET
(
std
::
vector
<
int
>
,
Subsets
)
int
CvRTreesWrapper
::
getVarCount
()
const
{
return
m_Impl
->
getVarCount
();
}
bool
CvRTreesWrapper
::
isTrained
()
const
{
return
m_Impl
->
isTrained
();
}
bool
CvRTreesWrapper
::
isClassifier
()
const
{
return
m_Impl
->
isClassifier
();
}
cv
::
Mat
CvRTreesWrapper
::
getVarImportance
()
const
{
return
m_Impl
->
getVarImportance
();
}
cv
::
String
CvRTreesWrapper
::
getDefaultName
()
const
{
return
m_Impl
->
getDefaultName
();
}
void
CvRTreesWrapper
::
read
(
const
cv
::
FileNode
&
fn
)
{
m_Impl
->
read
(
fn
);
}
void
CvRTreesWrapper
::
save
(
const
cv
::
String
&
filename
)
const
{
m_Impl
->
save
(
filename
);
}
bool
CvRTreesWrapper
::
train
(
cv
::
InputArray
samples
,
int
layout
,
cv
::
InputArray
responses
)
{
return
m_Impl
->
train
(
samples
,
layout
,
responses
);
}
bool
CvRTreesWrapper
::
train
(
const
cv
::
Ptr
<
cv
::
ml
::
TrainData
>&
trainData
,
int
flags
)
{
return
m_Impl
->
train
(
trainData
,
flags
);
}
float
CvRTreesWrapper
::
predict
(
cv
::
InputArray
samples
,
cv
::
OutputArray
results
,
int
flags
)
const
{
return
m_Impl
->
predict
(
samples
,
results
,
flags
);
}
cv
::
Ptr
<
CvRTreesWrapper
>
CvRTreesWrapper
::
create
()
{
return
cv
::
makePtr
<
CvRTreesWrapper
>
();
}
#undef OTB_CV_WRAP_IMPL
#undef OTB_CV_WRAP_IMPL_REF
#undef OTB_CV_WRAP_IMPL_CSTREF_GET
#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