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
220e7d52
Commit
220e7d52
authored
14 years ago
by
Julien Michel
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Applying the extract trick to perform faster memory print estimation
parent
f98be2dc
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
Projections/otbBundleToPerfectSensor.cxx
+44
-5
44 additions, 5 deletions
Projections/otbBundleToPerfectSensor.cxx
with
44 additions
and
5 deletions
Projections/otbBundleToPerfectSensor.cxx
+
44
−
5
View file @
220e7d52
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include
"itkFixedArray.h"
#include
"itkFixedArray.h"
#include
"otbPipelineMemoryPrintCalculator.h"
#include
"otbPipelineMemoryPrintCalculator.h"
#include
"itkExtractImageFilter.h"
namespace
otb
namespace
otb
{
{
...
@@ -72,6 +73,8 @@ int BundleToPerfectSensor::Execute(otb::ApplicationOptionsResult* parseResult)
...
@@ -72,6 +73,8 @@ int BundleToPerfectSensor::Execute(otb::ApplicationOptionsResult* parseResult)
typedef
otb
::
SimpleRcsPanSharpeningFusionImageFilter
<
PanImageType
,
XsImageType
,
XsImageType
>
FusionFilterType
;
typedef
otb
::
SimpleRcsPanSharpeningFusionImageFilter
<
PanImageType
,
XsImageType
,
XsImageType
>
FusionFilterType
;
typedef
itk
::
ExtractImageFilter
<
XsImageType
,
XsImageType
>
ExtractFilterType
;
// Read input images information
// Read input images information
PanReaderType
::
Pointer
preader
=
PanReaderType
::
New
();
PanReaderType
::
Pointer
preader
=
PanReaderType
::
New
();
preader
->
SetFileName
(
parseResult
->
GetParameterString
(
"InputPanchro"
));
preader
->
SetFileName
(
parseResult
->
GetParameterString
(
"InputPanchro"
));
...
@@ -142,20 +145,56 @@ int BundleToPerfectSensor::Execute(otb::ApplicationOptionsResult* parseResult)
...
@@ -142,20 +145,56 @@ int BundleToPerfectSensor::Execute(otb::ApplicationOptionsResult* parseResult)
otb
::
StandardWriterWatcher
w4
(
writer
,
resampler
,
"Perfect sensor fusion"
);
otb
::
StandardWriterWatcher
w4
(
writer
,
resampler
,
"Perfect sensor fusion"
);
// Estimate memory print
otb
::
PipelineMemoryPrintCalculator
::
Pointer
memoryPrintCalculator
=
otb
::
PipelineMemoryPrintCalculator
::
New
();
otb
::
PipelineMemoryPrintCalculator
::
Pointer
memoryPrintCalculator
=
otb
::
PipelineMemoryPrintCalculator
::
New
();
const
double
byteToMegabyte
=
1.
/
vcl_pow
(
2.0
,
20
);
const
double
byteToMegabyte
=
1.
/
vcl_pow
(
2.0
,
20
);
memoryPrintCalculator
->
SetDataToWrite
(
fusionFilter
->
GetOutput
());
memoryPrintCalculator
->
SetAvailableMemory
(
256
/
byteToMegabyte
);
// Trick to avoid having the resampler compute the whole
// deformation field
ExtractFilterType
::
Pointer
extractFilter
=
ExtractFilterType
::
New
();
extractFilter
->
SetInput
(
fusionFilter
->
GetOutput
());
XsImageType
::
RegionType
smallRegion
;
XsImageType
::
SizeType
smallSize
;
smallSize
.
Fill
(
100
);
XsImageType
::
IndexType
index
;
index
[
0
]
=
fusionFilter
->
GetOutput
()
->
GetLargestPossibleRegion
().
GetIndex
()[
0
]
+
fusionFilter
->
GetOutput
()
->
GetLargestPossibleRegion
().
GetSize
()[
0
]
/
2
-
50
;
index
[
1
]
=
fusionFilter
->
GetOutput
()
->
GetLargestPossibleRegion
().
GetIndex
()[
1
]
+
fusionFilter
->
GetOutput
()
->
GetLargestPossibleRegion
().
GetSize
()[
1
]
/
2
-
50
;
smallRegion
.
SetSize
(
smallSize
);
smallRegion
.
SetIndex
(
index
);
extractFilter
->
SetExtractionRegion
(
smallRegion
);
bool
smallRegionSuccess
=
smallRegion
.
Crop
(
fusionFilter
->
GetOutput
()
->
GetLargestPossibleRegion
());
if
(
smallRegionSuccess
)
{
memoryPrintCalculator
->
SetDataToWrite
(
extractFilter
->
GetOutput
());
double
regionTrickFactor
=
(
double
)
fusionFilter
->
GetOutput
()
->
GetLargestPossibleRegion
().
GetNumberOfPixels
()
/
(
double
)(
smallRegion
.
GetNumberOfPixels
());
memoryPrintCalculator
->
SetBiasCorrectionFactor
(
1.27
*
regionTrickFactor
);
}
else
{
memoryPrintCalculator
->
SetDataToWrite
(
fusionFilter
->
GetOutput
());
memoryPrintCalculator
->
SetBiasCorrectionFactor
(
1.27
);
}
memoryPrintCalculator
->
SetAvailableMemory
(
256
/
byteToMegabyte
);
if
(
parseResult
->
IsOptionPresent
(
"AvailableMemory"
))
if
(
parseResult
->
IsOptionPresent
(
"AvailableMemory"
))
{
{
long
long
int
memory
=
static_cast
<
long
long
int
>
(
parseResult
->
GetParameterUInt
(
"AvailableMemory"
));
long
long
int
memory
=
static_cast
<
long
long
int
>
(
parseResult
->
GetParameterUInt
(
"AvailableMemory"
));
memoryPrintCalculator
->
SetAvailableMemory
(
memory
/
byteToMegabyte
);
memoryPrintCalculator
->
SetAvailableMemory
(
memory
/
byteToMegabyte
);
}
}
memoryPrintCalculator
->
SetBiasCorrectionFactor
(
1.27
);
memoryPrintCalculator
->
Compute
();
memoryPrintCalculator
->
Compute
();
std
::
cout
<<
"Total memory usage: "
<<
memoryPrintCalculator
->
GetMemoryPrint
()
*
byteToMegabyte
<<
" Mb"
<<
std
::
endl
;
std
::
cout
<<
"Optimal stream division: "
<<
memoryPrintCalculator
->
GetOptimalNumberOfStreamDivisions
()
<<
std
::
endl
;
writer
->
SetTilingStreamDivisions
(
memoryPrintCalculator
->
GetOptimalNumberOfStreamDivisions
());
writer
->
SetTilingStreamDivisions
(
memoryPrintCalculator
->
GetOptimalNumberOfStreamDivisions
());
writer
->
Update
();
writer
->
Update
();
...
...
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