상세 컨텐츠

본문 제목

Levenberg-Marquardt tested!

학술

by 양고 2009. 2. 19. 22:10

본문

L-M을 이용한 실험 1차 완료. Lourakis의 구현을 이용하였다. 밤늦게까지 한 보람이 있는 하루이다. 사실 오늘 야근의 주목적은 구매서류 작성과 보고서 작성이었지만... ^^


초록색 원은 ground truth, 빨간 점은 points rendered with estimated parameters, 파란 점은 measurements with intermediate parameters. 의외로 수렴성과 속도가 괜찮아 보인다.

[2009.3.7 추가]
토요일에 나와서 디버그 성공...이라고 생각했지만, 실험하다보니 t에 에러가 발생하는 경우가 많다.
still t is not optimized quite often when zoom and rotation are combined.


dlevmar_der()
/*
* This function seeks the mx1 parameter vector p that best describes the nx1 measurements vector x.
* All computations are double precision.
* An analytic Jacobian is required. In case the latter is unavailable or expensive to compute,
* use dlevmar_dif() below.
*
* Returns the number of iterations (>=0) if successful, -1 if failed
*
*/

int dlevmar_der(
void (*func)(double *p, double *hx, int m, int n, void *adata), /* functional relation describing measurements.
                                                                 * A p \in R^m yields a \hat{x} \in  R^n
                                                                 */
void (*jacf)(double *p, double *j, int m, int n, void *adata),  /* function to evaluate the Jacobian \part x / \part p */
double *p,         /* I/O: initial parameter estimates. On output contains the estimated solution */
double *x,         /* I: measurement vector. NULL implies a zero vector */
int m,             /* I: parameter vector dimension (i.e. #unknowns) */
int n,             /* I: measurement vector dimension */
int itmax,         /* I: maximum number of iterations */
double opts[4],    /* I: minim. options [\tau, \epsilon1, \epsilon2, \epsilon3]. Respectively the scale factor for initial \mu,
                    * stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2. Set to NULL for defaults to be used
                    */
double info[LM_INFO_SZ],
                    /* O: information regarding the minimization. Set to NULL if don't care
                     * info[0]= ||e||_2 at initial p.
                     * info[1-4]=[ ||e||_2, ||J^T e||_inf,  ||Dp||_2, \mu/max[J^T J]_ii ], all computed at estimated p.
                     * info[5]= # iterations,
                     * info[6]=reason for terminating: 1 - stopped by small gradient J^T e
                     *                                 2 - stopped by small Dp
                     *                                 3 - stopped by itmax
                     *                                 4 - singular matrix. Restart from current p with increased \mu
                     *                                 5 - no further error reduction is possible. Restart with increased mu
                     *                                 6 - stopped by small ||e||_2
                     *                                 7 - stopped by invalid (i.e. NaN or Inf) "func" values; a user error
                     * info[7]= # function evaluations
                     * info[8]= # Jacobian evaluations
                     * info[9]= # linear systems solved, i.e. # attempts for reducing error
                     */
double *work,      /* I: pointer to working memory, allocated internally if NULL. If !=NULL, it is assumed to point to
                    * a memory chunk at least LM_DER_WORKSZ(m, n)*sizeof(double) bytes long
                    */
double *covar,     /* O: Covariance matrix corresponding to LS solution; Assumed to point to a mxm matrix.
                    * Set to NULL if not needed.
                    */
void *adata)       /* I: pointer to possibly needed additional data, passed uninterpreted to func & jacf.
                    * Set to NULL if not needed
                    */

dlevmar_dif()
/*
* Similar to dlevmar_der() except that the Jacobian is approximated internally with the aid of finite differences.
* Broyden's rank one updates are used to compute secant approximations to the Jacobian, effectively avoiding to call
* func several times for computing the finite difference approximations.
* If the analytic Jacobian is available, use dlevmar_der() above.
*
* Returns the number of iterations (>=0) if successful, -1 if failed
*
*/
int dlevmar_dif(
void (*func)(double *p, double *hx, int m, int n, void *adata), /* functional relation describing measurements.
                                                                 * A p \in R^m yields a \hat{x} \in  R^n
                                                                 */
double *p,         /* I/O: initial parameter estimates. On output contains the estimated solution */
double *x,         /* I: measurement vector. NULL implies a zero vector */
int m,             /* I: parameter vector dimension (i.e. #unknowns) */
int n,             /* I: measurement vector dimension */
int itmax,         /* I: maximum number of iterations */
double opts[5],    /* I: opts[0-4] = minim. options [\tau, \epsilon1, \epsilon2, \epsilon3, \delta]. Respectively the
                    * scale factor for initial \mu, stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2 and the
                    * step used in difference approximation to the Jacobian. If \delta<0, the Jacobian is approximated
                    * with central differences which are more accurate (but slower!) compared to the forward differences
                    * employed by default. Set to NULL for defaults to be used.
                    */
double info[LM_INFO_SZ],
                    /* O: information regarding the minimization. Set to NULL if don't care
                     * info[0]= ||e||_2 at initial p.
                     * info[1-4]=[ ||e||_2, ||J^T e||_inf,  ||Dp||_2, \mu/max[J^T J]_ii ], all computed at estimated p.
                     * info[5]= # iterations,
                     * info[6]=reason for terminating: 1 - stopped by small gradient J^T e
                     *                                 2 - stopped by small Dp
                     *                                 3 - stopped by itmax
                     *                                 4 - singular matrix. Restart from current p with increased \mu
                     *                                 5 - no further error reduction is possible. Restart with increased mu
                     *                                 6 - stopped by small ||e||_2
                     *                                 7 - stopped by invalid (i.e. NaN or Inf) "func" values; a user error
                     * info[7]= # function evaluations
                     * info[8]= # Jacobian evaluations
                     * info[9]= # linear systems solved, i.e. # attempts for reducing error
                     */
double *work,      /* I: working memory, allocated internally if NULL. If !=NULL, it is assumed to point to
                    * a memory chunk at least LM_DIF_WORKSZ(m, n)*sizeof(double) bytes long
                    */
double *covar,     /* O: Covariance matrix corresponding to LS solution; Assumed to point to a mxm matrix.
                    * Set to NULL if not needed.
                    */
void *adata)       /* I: pointer to possibly needed additional data, passed uninterpreted to func.
                    * Set to NULL if not needed
                    */









관련글 더보기