Package com.irurueta.geometry.refiners
Class DecomposedLinePlaneCorrespondencePinholeCameraRefiner
java.lang.Object
com.irurueta.geometry.refiners.Refiner<PinholeCamera>
com.irurueta.geometry.refiners.InliersDataRefiner<PinholeCamera>
com.irurueta.geometry.refiners.PairMatchesAndInliersDataRefiner<PinholeCamera,Plane,Line2D>
com.irurueta.geometry.refiners.PinholeCameraRefiner<Plane,Line2D>
com.irurueta.geometry.refiners.LinePlaneCorrespondencePinholeCameraRefiner
com.irurueta.geometry.refiners.DecomposedLinePlaneCorrespondencePinholeCameraRefiner
public class DecomposedLinePlaneCorrespondencePinholeCameraRefiner
extends LinePlaneCorrespondencePinholeCameraRefiner
A pinhole camera refiner using line/plane correspondences and the
Powell algorithm to try to decrease overall error in LMSE terms among
inlier samples by taking the decomposed parameters of a pinhole camera.
Typically, this refiner is used by a robust estimator, however it can also be
useful in some other situations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classListener for powell optimizer to minimize cost function during refinement. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleCurrent weight during refinement.static final doubleDefault value for maximum suggestion weight.static final doubleDefault value for minimum suggestion weight.static final doubleDefault value for the step to increase suggestion weight.private doubleMaximum suggestion weight.private doubleMinimum suggestion weight.private static final intDimensions for refinement.private PinholeCameraInstance of a pinhole camera to be reused during refinement.private doubleStep to increase suggestion weight.Fields inherited from class com.irurueta.geometry.refiners.PinholeCameraRefiner
DEFAULT_SUGGEST_ASPECT_RATIO_ENABLED, DEFAULT_SUGGEST_CENTER_ENABLED, DEFAULT_SUGGEST_HORIZONTAL_FOCAL_LENGTH_ENABLED, DEFAULT_SUGGEST_PRINCIPAL_POINT_ENABLED, DEFAULT_SUGGEST_ROTATION_ENABLED, DEFAULT_SUGGEST_SKEWNESS_VALUE_ENABLED, DEFAULT_SUGGEST_VERTICAL_FOCAL_LENGTH_ENABLED, DEFAULT_SUGGESTED_ASPECT_RATIO_VALUE, DEFAULT_SUGGESTED_SKEWNESS_VALUE, refinementStandardDeviationFields inherited from class com.irurueta.geometry.refiners.PairMatchesAndInliersDataRefiner
samples1, samples2Fields inherited from class com.irurueta.geometry.refiners.InliersDataRefiner
inliers, numInliers, residualsFields inherited from class com.irurueta.geometry.refiners.Refiner
covariance, DEFAULT_KEEP_COVARIANCE, initialEstimation, keepCovariance, listener, locked -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.DecomposedLinePlaneCorrespondencePinholeCameraRefiner(PinholeCamera initialEstimation, boolean keepCovariance, com.irurueta.numerical.robust.InliersData inliersData, List<Plane> samples1, List<Line2D> samples2, double refinementStandardDeviation) Constructor.DecomposedLinePlaneCorrespondencePinholeCameraRefiner(PinholeCamera initialEstimation, boolean keepCovariance, BitSet inliers, double[] residuals, int numInliers, List<Plane> samples1, List<Line2D> samples2, double refinementStandardDeviation) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate com.irurueta.algebra.MatrixestimateCovarianceLevenbergMarquardt(PinholeCamera pinholeCamera, double weight) Estimates covariance matrix for provided estimated and refined cameradoubleGets maximum suggestion weight.doubleGets minimum suggestion weight.doubleGets step to increase suggestion weight.booleanrefine(PinholeCamera result) Refines provided initial estimation.private booleanrefinementStepPowell(com.irurueta.numerical.optimization.PowellMultiOptimizer optimizer, DecomposedLinePlaneCorrespondencePinholeCameraRefiner.RefinementMultiDimensionFunctionEvaluatorListener listener, double[] startPoint, double weight) Computes one refinement step using Powell optimizer for a given weight on suggestion terms.private booleanrefinePowell(PinholeCamera result) Refines camera using Powell optimization to minimize a cost function consisting on the sum of squared projection residuals plus the suggestion residual for any suggested terms.voidsetMaxSuggestionWeight(double maxSuggestionWeight) Sets maximum suggestion weight.voidsetMinMaxSuggestionWeight(double minSuggestionWeight, double maxSuggestionWeight) Sets minimum and maximum suggestion weights.voidsetMinSuggestionWeight(double minSuggestionWeight) Sets minimum suggestion weight.voidsetSuggestionWeightStep(double suggestionWeightStep) Sets step to increase suggestion weight.Methods inherited from class com.irurueta.geometry.refiners.LinePlaneCorrespondencePinholeCameraRefiner
residualLevenbergMarquardt, residualPowellMethods inherited from class com.irurueta.geometry.refiners.PinholeCameraRefiner
cameraToParameters, getRefinementStandardDeviation, getSuggestedAspectRatioValue, getSuggestedCenterValue, getSuggestedHorizontalFocalLengthValue, getSuggestedPrincipalPointValue, getSuggestedRotationValue, getSuggestedSkewnessValue, getSuggestedVerticalFocalLengthValue, hasSuggestions, isSuggestAspectRatioEnabled, isSuggestCenterEnabled, isSuggestHorizontalFocalLengthEnabled, isSuggestPrincipalPointEnabled, isSuggestRotationEnabled, isSuggestSkewnessValueEnabled, isSuggestVerticalFocalLengthEnabled, parametersToCamera, refine, setRefinementStandardDeviation, setSuggestAspectRatioEnabled, setSuggestCenterEnabled, setSuggestedAspectRatioValue, setSuggestedCenterValue, setSuggestedHorizontalFocalLengthValue, setSuggestedPrincipalPointValue, setSuggestedRotationValue, setSuggestedSkewnessValue, setSuggestedVerticalFocalLengthValue, setSuggestHorizontalFocalLengthEnabled, setSuggestPrincipalPointEnabled, setSuggestRotationEnabled, setSuggestSkewnessValueEnabled, setSuggestVerticalFocalLengthEnabled, suggestionResidualMethods inherited from class com.irurueta.geometry.refiners.PairMatchesAndInliersDataRefiner
getSamples1, getSamples2, isReady, setSamples1, setSamples2Methods inherited from class com.irurueta.geometry.refiners.InliersDataRefiner
getInliers, getNumInliers, getResiduals, getTotalSamples, setInliers, setInliersData, setNumInliers, setResidualsMethods inherited from class com.irurueta.geometry.refiners.Refiner
getCovariance, getInitialEstimation, getListener, isCovarianceKept, isLocked, setCovarianceKept, setInitialEstimation, setListener
-
Field Details
-
DEFAULT_MIN_SUGGESTION_WEIGHT
public static final double DEFAULT_MIN_SUGGESTION_WEIGHTDefault value for minimum suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones.- See Also:
-
DEFAULT_MAX_SUGGESTION_WEIGHT
public static final double DEFAULT_MAX_SUGGESTION_WEIGHTDefault value for maximum suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones.- See Also:
-
DEFAULT_SUGGESTION_WEIGHT_STEP
public static final double DEFAULT_SUGGESTION_WEIGHT_STEPDefault value for the step to increase suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones.- See Also:
-
REFINE_DIMS
private static final int REFINE_DIMSDimensions for refinement.- See Also:
-
minSuggestionWeight
private double minSuggestionWeightMinimum suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones. -
maxSuggestionWeight
private double maxSuggestionWeightMaximum suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones. -
suggestionWeightStep
private double suggestionWeightStepStep to increase suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones. -
refineCamera
Instance of a pinhole camera to be reused during refinement. -
currentWeight
private double currentWeightCurrent weight during refinement.
-
-
Constructor Details
-
DecomposedLinePlaneCorrespondencePinholeCameraRefiner
public DecomposedLinePlaneCorrespondencePinholeCameraRefiner()Constructor. -
DecomposedLinePlaneCorrespondencePinholeCameraRefiner
public DecomposedLinePlaneCorrespondencePinholeCameraRefiner(PinholeCamera initialEstimation, boolean keepCovariance, BitSet inliers, double[] residuals, int numInliers, List<Plane> samples1, List<Line2D> samples2, double refinementStandardDeviation) Constructor.- Parameters:
initialEstimation- initial estimation to be set.keepCovariance- true if covariance of estimation must be kept after refinement, false otherwise.inliers- set indicating which of the provided matches are inliers.residuals- residuals for matched samples.numInliers- number of inliers on initial estimation.samples1- 1st set of paired samples.samples2- 2nd set of paired samples.refinementStandardDeviation- standard deviation used for Levenberg-Marquardt fitting.
-
DecomposedLinePlaneCorrespondencePinholeCameraRefiner
public DecomposedLinePlaneCorrespondencePinholeCameraRefiner(PinholeCamera initialEstimation, boolean keepCovariance, com.irurueta.numerical.robust.InliersData inliersData, List<Plane> samples1, List<Line2D> samples2, double refinementStandardDeviation) Constructor.- Parameters:
initialEstimation- initial estimation to be set.keepCovariance- true if covariance of estimation must be kept after refinement, false otherwise.inliersData- inlier data, typically obtained from a robust estimator.samples1- 1st set of paired samples.samples2- 2nd set of paired samples.refinementStandardDeviation- standard deviation used for Levenberg-Marquardt fitting.
-
-
Method Details
-
getMinSuggestionWeight
public double getMinSuggestionWeight()Gets minimum suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones.- Returns:
- minimum suggestion weight.
-
setMinSuggestionWeight
Sets minimum suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones.- Parameters:
minSuggestionWeight- minimum suggestion weight.- Throws:
LockedException- if estimator is locked.
-
getMaxSuggestionWeight
public double getMaxSuggestionWeight()Gets maximum suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones.- Returns:
- maximum suggestion weight.
-
setMaxSuggestionWeight
Sets maximum suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones.- Parameters:
maxSuggestionWeight- maximum suggestion weight.- Throws:
LockedException- if estimator is locked.
-
setMinMaxSuggestionWeight
public void setMinMaxSuggestionWeight(double minSuggestionWeight, double maxSuggestionWeight) throws LockedException Sets minimum and maximum suggestion weights. Suggestion weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones.- Parameters:
minSuggestionWeight- minimum suggestion weight.maxSuggestionWeight- maximum suggestion weight.- Throws:
LockedException- if estimator is locked.IllegalArgumentException- if minimum suggestion weight is greater or equal than maximum value.
-
getSuggestionWeightStep
public double getSuggestionWeightStep()Gets step to increase suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones.- Returns:
- step to increase suggestion weight.
-
setSuggestionWeightStep
Sets step to increase suggestion weight. This weight is used to slowly draw original camera parameters into desired suggested values. Suggestion weight slowly increases each time Levenberg-Marquardt is used to find a solution so that the algorithm can converge into desired value. The faster the weights are increased the less likely that suggested values can be converged if they differ too much from the original ones.- Parameters:
suggestionWeightStep- step to increase suggestion weight.- Throws:
LockedException- if estimator is locked.IllegalArgumentException- if provided step is negative or zero.
-
refine
Refines provided initial estimation. This method always sets a value into provided result instance regardless of the fact that error has actually improved in LMSE terms or not.- Specified by:
refinein classRefiner<PinholeCamera>- Parameters:
result- instance where refined estimation will be stored.- Returns:
- true if result improves (decreases) in LMSE terms respect to initial estimation, false if no improvement has been achieved.
- Throws:
NotReadyException- if not enough input data has been provided.LockedException- if estimator is locked because refinement is already in progress.
-
estimateCovarianceLevenbergMarquardt
private com.irurueta.algebra.Matrix estimateCovarianceLevenbergMarquardt(PinholeCamera pinholeCamera, double weight) Estimates covariance matrix for provided estimated and refined camera- Parameters:
pinholeCamera- pinhole camera to estimate covariance for.weight- weight for suggestion residual.- Returns:
- estimated covariance or null if anything fails.
-
refinePowell
Refines camera using Powell optimization to minimize a cost function consisting on the sum of squared projection residuals plus the suggestion residual for any suggested terms.- Parameters:
result- instance where refined estimation will be stored.- Returns:
- true if result improves (decreases) in LMSE terms respect to initial estimation, false if no improvement has been achieved.
-
refinementStepPowell
private boolean refinementStepPowell(com.irurueta.numerical.optimization.PowellMultiOptimizer optimizer, DecomposedLinePlaneCorrespondencePinholeCameraRefiner.RefinementMultiDimensionFunctionEvaluatorListener listener, double[] startPoint, double weight) throws GeometryException, com.irurueta.numerical.NumericalException Computes one refinement step using Powell optimizer for a given weight on suggestion terms.- Parameters:
optimizer- Powell optimizer to be reused.listener- Powell optimizer listener to be reused.startPoint- starting point for powell optimization. This array is passed only for reuse purposes.weight- suggestion terms weight.- Returns:
- true if this refinement step decreased projection error in LMSE terms, false otherwise.
- Throws:
GeometryException- if something failed.com.irurueta.numerical.NumericalException- if something failed.
-