Skip to content
Snippets Groups Projects
Commit 6afcada3 authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Relaxing the constraints on the number of required points by explicitly...

ENH: Relaxing the constraints on the number of required points by explicitly disabling elevation if not enough points are provided
parent 1b933e33
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@
#include "otbRPCSolverAdapter.h"
#include "otbImageKeywordlist.h"
#include "otbMacro.h"
#include "ossim/projection/ossimRpcSolver.h"
#include "ossim/projection/ossimProjection.h"
......@@ -68,13 +69,25 @@ RPCSolverAdapter::Solve(const GCPsContainerType& gcpContainer,
}
// Check for enough points
if(sensorPoints.size() < 40)
if(sensorPoints.size() < 20)
{
itkGenericExceptionMacro(<<"At least 40 points are required to estimate the 80 parameters of the RPC model, but only "<<sensorPoints.size()<<" were given.");
itkGenericExceptionMacro(<<"At least 20 points are required to estimate the 40 parameters of a RPC model without elevation support, and 40 are required to estimate the 80 parameters of a RPC model with elevation support. Only "<<sensorPoints.size()<<" points were given.");
}
// By default, use elevation provided with ground control points
bool useElevation = true;
// If not enough points are given for a proper estimation of RPC
// with elevation support, disable elevation. This will result in
// all coefficients related to elevation set to zero.
if(sensorPoints.size()<40)
{
otbGenericWarningMacro("Only "<<sensorPoints.size()<<" ground control points are provided, can not estimate a RPC model with elevation support (at least 40 points required). Elevation support will be disabled for RPC estimation. All coefficients related to elevation will be set to zero, and elevation will have no effect on the resulting transform.");
useElevation = false;
}
// Build the ossim rpc solver
ossimRefPtr<ossimRpcSolver> rpcSolver = new ossimRpcSolver(true, false);
ossimRefPtr<ossimRpcSolver> rpcSolver = new ossimRpcSolver(useElevation, false);
// Call the solve method
rpcSolver->solveCoefficients(sensorPoints, geoPoints);
......
......@@ -54,13 +54,18 @@ public:
/** Solve RPC modelling from a set of GCPs and image bounds.
* The estimated RPC model is written in a keywordlist understood
* by other OTB and classes (like GenericRSTransform for instance).
* Please note that at least 20 points are required to estimate the
* RPC model. Between 20 and 40 points, the estimated model will
* not provide elevation support, since there are not enough points
* to estimate all the coefficients. Starting at 40 points, a full
* RPC model is estimated.
*/
static void Solve(const GCPsContainerType& gcpContainer,
double& rmsError,
ImageKeywordlist& otb_kwl);
/** Solve RPC modelling from a set of GCPs and image bounds. The
* estimated RPC model is written to a geom file
* estimated RPC model is written to a geom file.
*/
static bool Solve(const GCPsContainerType& gcpContainer,
double& rmsError,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment