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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
David Youssefi
otb
Commits
536dcdbd
Commit
536dcdbd
authored
14 years ago
by
Julien Malik
Browse files
Options
Downloads
Patches
Plain Diff
ADD: add an svm creation test for Object Detection
parent
0aaab2a3
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Testing/Code/ObjectDetection/otbDescriptorsListSampleGenerator.cxx
+77
-9
77 additions, 9 deletions
...ode/ObjectDetection/otbDescriptorsListSampleGenerator.cxx
with
77 additions
and
9 deletions
Testing/Code/ObjectDetection/otbDescriptorsListSampleGenerator.cxx
+
77
−
9
View file @
536dcdbd
...
...
@@ -32,6 +32,8 @@
#include
"otbVectorDataFileReader.h"
#include
"otbImageFunctionAdaptor.h"
#include
"otbSVMSampleListModelEstimator.h"
const
unsigned
int
Dimension
=
2
;
typedef
int
LabelType
;
typedef
double
PixelType
;
...
...
@@ -41,14 +43,13 @@ typedef double CoordRepType;
typedef
otb
::
Image
<
PixelType
,
Dimension
>
ImageType
;
typedef
otb
::
VectorData
<>
VectorDataType
;
typedef
otb
::
RadiometricMomentsImageFunction
<
ImageType
,
CoordRepType
>
FunctionType
;
typedef
otb
::
ImageFunctionAdaptor
<
FunctionType
>
AdapatedFunctionType
;
typedef
otb
::
ImageFunctionAdaptor
<
FunctionType
>
AdapatedFunctionType
;
//typedef FunctionType::OutputType SampleType;
typedef
itk
::
VariableLengthVector
<
CoordRepType
>
SampleType
;
typedef
itk
::
Statistics
::
ListSample
<
SampleType
>
ListSampleType
;
typedef
itk
::
FixedArray
<
LabelType
>
LabelSampleType
;
typedef
itk
::
Statistics
::
ListSample
<
LabelSampleType
>
LabelListSampleType
;
typedef
itk
::
VariableLengthVector
<
FunctionPrecisionType
>
SampleType
;
typedef
itk
::
Statistics
::
ListSample
<
SampleType
>
ListSampleType
;
typedef
itk
::
FixedArray
<
LabelType
>
LabelSampleType
;
typedef
itk
::
Statistics
::
ListSample
<
LabelSampleType
>
LabelListSampleType
;
typedef
otb
::
DescriptorsListSampleGenerator
<
ImageType
,
...
...
@@ -61,10 +62,18 @@ typedef otb::DescriptorsListSampleGenerator
typedef
otb
::
ImageFileReader
<
ImageType
>
ImageReaderType
;
typedef
otb
::
VectorDataFileReader
<
VectorDataType
>
VectorDataReaderType
;
typedef
otb
::
Functor
::
VariableLengthVectorToMeasurementVectorFunctor
<
SampleType
>
MeasurementVectorFunctorType
;
typedef
otb
::
SVMSampleListModelEstimator
<
ListSampleType
,
LabelListSampleType
,
MeasurementVectorFunctorType
>
SVMEstimatorType
;
typedef
FunctionType
::
PointType
PointType
;
typedef
DescriptorsListSampleGeneratorType
::
SamplesPositionType
SamplesPositionType
;
struct
SampleEntry
{
PointType
position
;
...
...
@@ -112,7 +121,7 @@ int otbDescriptorsListSampleGeneratorNew(int itkNotUsed(argc), char* itkNotUsed(
int
otbDescriptorsListSampleGenerator
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
5
)
if
(
argc
!=
6
)
{
std
::
cerr
<<
"Wrong number of arguments"
<<
std
::
endl
;
return
EXIT_FAILURE
;
...
...
@@ -122,6 +131,7 @@ int otbDescriptorsListSampleGenerator(int argc, char* argv[])
const
char
*
inputSamplesLocation
=
argv
[
2
];
const
char
*
outputFileName
=
argv
[
3
];
int
streaming
=
atoi
(
argv
[
4
]);
int
neighborhood
=
atoi
(
argv
[
5
]);
ImageReaderType
::
Pointer
imageReader
=
ImageReaderType
::
New
();
imageReader
->
SetFileName
(
inputImageFileName
);
...
...
@@ -140,7 +150,7 @@ int otbDescriptorsListSampleGenerator(int argc, char* argv[])
descriptorsGenerator
->
SetInputImage
(
imageReader
->
GetOutput
());
descriptorsGenerator
->
SetSamplesLocations
(
vectorDataReader
->
GetOutput
());
descriptorsGenerator
->
SetDescriptorsFunction
(
descriptorsFunction
.
GetPointer
());
descriptorsGenerator
->
SetNeighborhoodRadius
(
5
);
descriptorsGenerator
->
SetNeighborhoodRadius
(
neighborhood
);
if
(
streaming
==
0
)
{
...
...
@@ -189,3 +199,61 @@ int otbDescriptorsListSampleGenerator(int argc, char* argv[])
return
EXIT_SUCCESS
;
}
int
otbDescriptorsSVMModelCreation
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
6
)
{
std
::
cerr
<<
"Wrong number of arguments"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
const
char
*
inputImageFileName
=
argv
[
1
];
const
char
*
inputSamplesLocation
=
argv
[
2
];
const
char
*
outputFileName
=
argv
[
3
];
int
streaming
=
atoi
(
argv
[
4
]);
int
neighborhood
=
atoi
(
argv
[
5
]);
ImageReaderType
::
Pointer
imageReader
=
ImageReaderType
::
New
();
imageReader
->
SetFileName
(
inputImageFileName
);
VectorDataReaderType
::
Pointer
vectorDataReader
=
VectorDataReaderType
::
New
();
vectorDataReader
->
SetFileName
(
inputSamplesLocation
);
//imageReader->Update();
//vectorDataReader->Update();
AdapatedFunctionType
::
Pointer
descriptorsFunction
=
AdapatedFunctionType
::
New
();
descriptorsFunction
->
SetInputImage
(
imageReader
->
GetOutput
());
descriptorsFunction
->
GetInternalImageFunction
()
->
SetNeighborhoodRadius
(
neighborhood
);
DescriptorsListSampleGeneratorType
::
Pointer
descriptorsGenerator
=
DescriptorsListSampleGeneratorType
::
New
();
descriptorsGenerator
->
SetInputImage
(
imageReader
->
GetOutput
());
descriptorsGenerator
->
SetSamplesLocations
(
vectorDataReader
->
GetOutput
());
descriptorsGenerator
->
SetDescriptorsFunction
(
descriptorsFunction
.
GetPointer
());
descriptorsGenerator
->
SetNeighborhoodRadius
(
5
);
if
(
streaming
==
0
)
{
descriptorsGenerator
->
GetStreamer
()
->
SetNumberOfStreamDivisions
(
1
);
}
else
{
descriptorsGenerator
->
GetStreamer
()
->
SetNumberOfStreamDivisions
(
streaming
);
}
descriptorsGenerator
->
Update
();
SVMEstimatorType
::
Pointer
svmEstimator
=
SVMEstimatorType
::
New
();
svmEstimator
->
SetInputSampleList
(
descriptorsGenerator
->
GetListSample
());
svmEstimator
->
SetTrainingSampleList
(
descriptorsGenerator
->
GetLabelListSample
());
svmEstimator
->
Update
();
svmEstimator
->
GetModel
()
->
SaveModel
(
outputFileName
);
return
EXIT_SUCCESS
;
}
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