IterativeNonlinearLSTSQ¶
- class giant.calibration.estimators.geometric.iterative_nonlinear_lstsq.IterativeNonlinearLSTSQ(model, options=None)[source]¶
This concrete estimator implements iterative non-linear least squares for estimating an updated camera model.
Iterative non-linear least squares estimation is done by estimating updates to the “state” vector (in this case the camera model parameters being updated) iteratively. At each step, the system is linearized about the current estimate of the state and the additive update is estimated. This iteration is repeated until convergence (or divergence) based on the pre/post update residuals and the update vector itself.
The state vector that is being estimated by this class is controlled by the
CameraModel.estimation_parametersattribute of the provided camera model. This class does not actually use theCameraModel.estimation_parametersattribute since it is handled by theCameraModel.compute_jacobian()andCameraModel.apply_update()methods of the provided camera model internally, but it is mentioned here to show how to control what exactly is being estimated.Because this class linearizes about the current estimate of the state, it requires an initial guess for the camera model that is “close enough” to the actual model to ensure convergence. Defining “close enough” in any broad sense is impossible, but based on experience, using the manufacturer defined specs for focal length/pixel pitch and assuming no distortion is generally “close enough” even for cameras with heavy distortion (star identification may require a better initial model than this anyway).
As this class converges the state estimate, it updates the supplied camera model in place, therefore, if you wish to keep a copy of the original camera model, you should manually create a copy of it before calling the
estimate()method on this class.In the
estimate()method, convergence is checked on both the sum of squares of the residuals and the update vector for the state. That is convergence is reached when either of\begin{gather*} \left\|\mathbf{r}_{pre}^T\mathbf{r}_{pre} - \mathbf{r}_{post}^T\mathbf{r}_{post}\right\| \le(a_r+r_r\mathbf{r}_{pre}^T\mathbf{r}_{pre}) \\ \text{all}\left[\left\|\mathbf{u}\right\|\le(a_s+r_s\mathbf{s}_{pre})\right] \end{gather*}is
True. Here \(\mathbf{r}_{pre}\) is the nx1 vector of residuals before the update is applied, \(\mathbf{r}_{post}\) is the nx1 vector of residuals after the update is applied, \(a_r\) is theresidual_atolabsolute residual tolerance, \(r_r\) is theresidual_rtolrelative residual tolerance, \(\mathbf{u}\) is the update vector, \(\text{all}\) indicates that the contained expression isTruefor all elements, \(a_s\) is thestate_atolabsolute tolerance for the state vector, \(r_s\) is thestate_rtolrelative tolerance for the state vector, and \(\mathbf{s}_{pre}\) is the state vector before the update is applied. Divergence is only checked on the sum of squares of the residuals, that is, divergence is occurring when\[\mathbf{r}_{pre}^T\mathbf{r}_{pre} < \mathbf{r}_{post}^T\mathbf{r}_{post}\]where all is as defined as before. If a case is diverging then a warning will be printed, the iteration will cease, and
successfulwill be set toFalse.Typically this class is not used by the user, and instead it is used internally by the
Calibrationclass which handles data preparation for you. If you wish to use this externally from theCalibrationclass you must first setmodelmeasurementscamera_frame_directionstemperaturesweighted_estimationmeasurement_covarianceifweighted_estimationisTruea_priori_state_covarianceifuse_a_prioriis set toTruefor the camera model.
according to their documentation. Once those have been set, you can perform the estimation using
estimate()which will iterate until convergence (or divergence). If the fit successfully converges,successfulwill be set toTrueand attributespostfit_covarianceandpostfit_residualswill both return numpy arrays instead ofNone. If you wish to use the same instance of this class to do another estimation you should callreset()before setting the new data to ensure that data is not mixed between estimation runs and all flags are set correctly.- Parameters:
model (ModelT) – The camera model instance to be estimated set with an initial guess of the state.
options (IterativeNonlinearLstSqOptions | None) – the dataclass containing the options to configure the class with
Methods
This method computes the observed minus computed residuals for the current model (or an input model). |
|
Estimates an updated camera model that better transforms the camera frame directions into pixel locations to minimize the residuals between the observed and the predicted star locations. |
|
This method resets all of the data attributes to their default values to prepare for another estimation. |