稀疏包调整实现c / c ++

时间:2011-11-22 12:57:26

标签: c++ debugging camera computer-vision

有人可以向我解释,以下功能等待的参数是什么,它们用于什么? 我有理解给定描述的问题。我想我传递了导致内存异常的错误参数。遗憾的是,异常无法调试,因为它是来自库的外部代码。

此功能用于计算顶点的3D位置,仅给出在不同视图中显示3D场景的各种图像上这些点的投影。

这里是函数头:

int sba_motstr_levmar_x(

const int n,   /* number of points */
const int ncon,/* number of points (starting from the 1st) whose parameters should not be modified.
               * All B_ij (see below) with i<ncon are assumed to be zero
               */
const int m,   /* number of images */
const int mcon,/* number of images (starting from the 1st) whose parameters should not be modified.
                          * All A_ij (see below) with j<mcon are assumed to be zero
                          */


char *vmask,  /* visibility mask: vmask[i, j]=1 if point i visible in image j, 0 otherwise. nxm */
double *p,    /* initial parameter vector p0: (a1, ..., am, b1, ..., bn).
               * aj are the image j parameters, bi are the i-th point parameters,
               * size m*cnp + n*pnp
               */
const int cnp,/* number of parameters for ONE camera; e.g. 6 for Euclidean cameras */
const int pnp,/* number of parameters for ONE point; e.g. 3 for Euclidean points */
double *x,    /* measurements vector: (x_11^T, .. x_1m^T, ..., x_n1^T, .. x_nm^T)^T where
               * x_ij is the projection of the i-th point on the j-th image.
               * NOTE: some of the x_ij might be missing, if point i is not visible in image j;
               * see vmask[i, j], max. size n*m*mnp
               */
double *covx, /* measurements covariance matrices: (Sigma_x_11, .. Sigma_x_1m, ..., Sigma_x_n1, .. Sigma_x_nm),
               * where Sigma_x_ij is the mnp x mnp covariance of x_ij stored row-by-row. Set to NULL if no
               * covariance estimates are available (identity matrices are implicitly used in this case).
               * NOTE: a certain Sigma_x_ij is missing if the corresponding x_ij is also missing;
               * see vmask[i, j], max. size n*m*mnp*mnp
               */
const int mnp,/* number of parameters for EACH measurement; usually 2 */
void (*func)(double *p, struct sba_crsm *idxij, int *rcidxs, int *rcsubs, double *hx, void *adata),
                                          /* functional relation describing measurements. Given a parameter vector p,
                                           * computes a prediction of the measurements \hat{x}. p is (m*cnp + n*pnp)x1,
                                           * \hat{x} is (n*m*mnp)x1, maximum
                                           * rcidxs, rcsubs are max(m, n) x 1, allocated by the caller and can be used
                                           * as working memory
                                           */
void (*fjac)(double *p, struct sba_crsm *idxij, int *rcidxs, int *rcsubs, double *jac, void *adata),
                                          /* function to evaluate the sparse Jacobian dX/dp.
                                           * The Jacobian is returned in jac as
                                           * (dx_11/da_1, ..., dx_1m/da_m, ..., dx_n1/da_1, ..., dx_nm/da_m,
                                           *  dx_11/db_1, ..., dx_1m/db_1, ..., dx_n1/db_n, ..., dx_nm/db_n), or
                                           * (using HZ's notation),
                                           * jac=(A_11, B_11, ..., A_1m, B_1m, ..., A_n1, B_n1, ..., A_nm, B_nm)
                                           * Notice that depending on idxij, some of the A_ij and B_ij might be missing.
                                           * Note also that A_ij and B_ij are mnp x cnp and mnp x pnp matrices resp. and
                                           * should be stored in jac in row-major order.
                                           * rcidxs, rcsubs are max(m, n) x 1, allocated by the caller and can be used
                                           * as working memory
                                           *
                                           * If NULL, the Jacobian is approximated by repetitive func calls and finite
                                           * differences. This is computationally inefficient and thus NOT recommended.
                                           */
void *adata,       /* pointer to possibly additional data, passed uninterpreted to func, fjac */ 

const int itmax,   /* I: maximum number of iterations. itmax==0 signals Jacobian verification followed by immediate return */
const int verbose, /* I: verbosity */
const double opts[SBA_OPTSSZ],
                   /* I: minim. options [\mu, \epsilon1, \epsilon2, \epsilon3, \epsilon4]. Respectively the scale factor for
                    * initial \mu, stopping thresholds for ||J^T e||_inf, ||dp||_2, ||e||_2 and (||e||_2-||e_new||_2)/||e||_2
                    */
double info[SBA_INFOSZ]
                   /* 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 - stopped by small relative reduction in ||e||_2
                    *                                 5 - stopped by small ||e||_2
                    *                                 6 - too many attempts to increase damping. Restart with increased mu
                    *                                 7 - stopped by invalid (i.e. NaN or Inf) "func" values; a user error
                    * info[7]= # function evaluations
                    * info[8]= # Jacobian evaluations
                    * info[9]= # number of linear systems solved, i.e. number of attempts for reducing error
                    */

为了更好的阅读,请访问此链接并滚动到“可用功能”:

http://www.ics.forth.gr/~lourakis/sba/#documentation

这也是该图书馆的官方主页。

1 个答案:

答案 0 :(得分:2)

通常,束调整是迭代技术,需要对外部摄像机参数进行合理的初始估计。你有吗?如果没有,Levenberg-Marquardt优化器可以收敛到局部最小值,最终会得出无用的结果。您可以在此处找到您可能感兴趣的其他资源。我不认为他们需要良好的初步估计:

资源I:

  

http://www.maths.lth.se/vision/downloads/

     

具有异常值的两个视图几何估计

     

用于查找两个校准的相对方向的C ++代码   存在异常值的相机。获得的解决方案是最佳的   意味着内部数量最大化。

资源II:

  

http://www.halcon.com/halcon/download/documentation/reference-9.0/hdevelop/toc_tools_stereo.html

     

vector_to_rel_pose

     

计算两者之间的相对方向   相机给出了图像点对应关系和已知的相机参数   并重建三维空间点。