Note that there are some explanatory texts on larger screens.

plurals
  1. POstack debugging in VS2008
    primarykey
    data
    text
    <p>I am doing some editings with an original source code in OpenCV package to do my tasks. There have been some other compilation errors after my modification. But I've already fixed them. Here comes the last one that I don't know how to remove it: </p> <p><img src="https://i.stack.imgur.com/btASp.jpg" alt="enter image description here"></p> <p>moreover, this run-time error does not give any output to the command line to ease the debugging</p> <p>Is there any solution when bugs come out like this??</p> <p>PS: the original code is the function cvFindExtrinsicCameraParams2 of calib3d.cpp </p> <p>for convinience, I post the original OpenCV function here: </p> <pre><code>CV_IMPL void cvFindExtrinsicCameraParams2( const CvMat* objectPoints, const CvMat* imagePoints, const CvMat* A, const CvMat* distCoeffs, CvMat* rvec, CvMat* tvec, int useExtrinsicGuess ) { const int max_iter = 20; Ptr&lt;CvMat&gt; matM, _Mxy, _m, _mn, matL, matJ; int i, count; double a[9], ar[9]={1,0,0,0,1,0,0,0,1}, R[9]; double MM[9], U[9], V[9], W[3]; CvScalar Mc; double param[6]; CvMat matA = cvMat( 3, 3, CV_64F, a ); CvMat _Ar = cvMat( 3, 3, CV_64F, ar ); CvMat matR = cvMat( 3, 3, CV_64F, R ); CvMat _r = cvMat( 3, 1, CV_64F, param ); CvMat _t = cvMat( 3, 1, CV_64F, param + 3 ); CvMat _Mc = cvMat( 1, 3, CV_64F, Mc.val ); CvMat _MM = cvMat( 3, 3, CV_64F, MM ); CvMat matU = cvMat( 3, 3, CV_64F, U ); CvMat matV = cvMat( 3, 3, CV_64F, V ); CvMat matW = cvMat( 3, 1, CV_64F, W ); CvMat _param = cvMat( 6, 1, CV_64F, param ); CvMat _dpdr, _dpdt; CV_Assert( CV_IS_MAT(objectPoints) &amp;&amp; CV_IS_MAT(imagePoints) &amp;&amp; CV_IS_MAT(A) &amp;&amp; CV_IS_MAT(rvec) &amp;&amp; CV_IS_MAT(tvec) ); count = MAX(objectPoints-&gt;cols, objectPoints-&gt;rows); matM = cvCreateMat( 1, count, CV_64FC3 ); _m = cvCreateMat( 1, count, CV_64FC2 ); cvConvertPointsHomogeneous( objectPoints, matM ); cvConvertPointsHomogeneous( imagePoints, _m ); cvConvert( A, &amp;matA ); CV_Assert( (CV_MAT_DEPTH(rvec-&gt;type) == CV_64F || CV_MAT_DEPTH(rvec-&gt;type) == CV_32F) &amp;&amp; (rvec-&gt;rows == 1 || rvec-&gt;cols == 1) &amp;&amp; rvec-&gt;rows*rvec-&gt;cols*CV_MAT_CN(rvec-&gt;type) == 3 ); CV_Assert( (CV_MAT_DEPTH(tvec-&gt;type) == CV_64F || CV_MAT_DEPTH(tvec-&gt;type) == CV_32F) &amp;&amp; (tvec-&gt;rows == 1 || tvec-&gt;cols == 1) &amp;&amp; tvec-&gt;rows*tvec-&gt;cols*CV_MAT_CN(tvec-&gt;type) == 3 ); _mn = cvCreateMat( 1, count, CV_64FC2 ); _Mxy = cvCreateMat( 1, count, CV_64FC2 ); // normalize image points // (unapply the intrinsic matrix transformation and distortion) cvUndistortPoints( _m, _mn, &amp;matA, distCoeffs, 0, &amp;_Ar ); if( useExtrinsicGuess ) { CvMat _r_temp = cvMat(rvec-&gt;rows, rvec-&gt;cols, CV_MAKETYPE(CV_64F,CV_MAT_CN(rvec-&gt;type)), param ); CvMat _t_temp = cvMat(tvec-&gt;rows, tvec-&gt;cols, CV_MAKETYPE(CV_64F,CV_MAT_CN(tvec-&gt;type)), param + 3); cvConvert( rvec, &amp;_r_temp ); cvConvert( tvec, &amp;_t_temp ); } else { Mc = cvAvg(matM); cvReshape( matM, matM, 1, count ); cvMulTransposed( matM, &amp;_MM, 1, &amp;_Mc ); cvSVD( &amp;_MM, &amp;matW, 0, &amp;matV, CV_SVD_MODIFY_A + CV_SVD_V_T ); // initialize extrinsic parameters if( W[2]/W[1] &lt; 1e-3 || count &lt; 4 ) { // a planar structure case (all M's lie in the same plane) double tt[3], h[9], h1_norm, h2_norm; CvMat* R_transform = &amp;matV; CvMat T_transform = cvMat( 3, 1, CV_64F, tt ); CvMat matH = cvMat( 3, 3, CV_64F, h ); CvMat _h1, _h2, _h3; if( V[2]*V[2] + V[5]*V[5] &lt; 1e-10 ) cvSetIdentity( R_transform ); if( cvDet(R_transform) &lt; 0 ) cvScale( R_transform, R_transform, -1 ); cvGEMM( R_transform, &amp;_Mc, -1, 0, 0, &amp;T_transform, CV_GEMM_B_T ); for( i = 0; i &lt; count; i++ ) { const double* Rp = R_transform-&gt;data.db; const double* Tp = T_transform.data.db; const double* src = matM-&gt;data.db + i*3; double* dst = _Mxy-&gt;data.db + i*2; dst[0] = Rp[0]*src[0] + Rp[1]*src[1] + Rp[2]*src[2] + Tp[0]; dst[1] = Rp[3]*src[0] + Rp[4]*src[1] + Rp[5]*src[2] + Tp[1]; } cvFindHomography( _Mxy, _mn, &amp;matH ); if( cvCheckArr(&amp;matH, CV_CHECK_QUIET) ) { cvGetCol( &amp;matH, &amp;_h1, 0 ); _h2 = _h1; _h2.data.db++; _h3 = _h2; _h3.data.db++; h1_norm = sqrt(h[0]*h[0] + h[3]*h[3] + h[6]*h[6]); h2_norm = sqrt(h[1]*h[1] + h[4]*h[4] + h[7]*h[7]); cvScale( &amp;_h1, &amp;_h1, 1./MAX(h1_norm, DBL_EPSILON) ); cvScale( &amp;_h2, &amp;_h2, 1./MAX(h2_norm, DBL_EPSILON) ); cvScale( &amp;_h3, &amp;_t, 2./MAX(h1_norm + h2_norm, DBL_EPSILON)); cvCrossProduct( &amp;_h1, &amp;_h2, &amp;_h3 ); cvRodrigues2( &amp;matH, &amp;_r ); cvRodrigues2( &amp;_r, &amp;matH ); cvMatMulAdd( &amp;matH, &amp;T_transform, &amp;_t, &amp;_t ); cvMatMul( &amp;matH, R_transform, &amp;matR ); } else { cvSetIdentity( &amp;matR ); cvZero( &amp;_t ); } cvRodrigues2( &amp;matR, &amp;_r ); } else { // non-planar structure. Use DLT method double* L; double LL[12*12], LW[12], LV[12*12], sc; CvMat _LL = cvMat( 12, 12, CV_64F, LL ); CvMat _LW = cvMat( 12, 1, CV_64F, LW ); CvMat _LV = cvMat( 12, 12, CV_64F, LV ); CvMat _RRt, _RR, _tt; CvPoint3D64f* M = (CvPoint3D64f*)matM-&gt;data.db; CvPoint2D64f* mn = (CvPoint2D64f*)_mn-&gt;data.db; matL = cvCreateMat( 2*count, 12, CV_64F ); L = matL-&gt;data.db; for( i = 0; i &lt; count; i++, L += 24 ) { double x = -mn[i].x, y = -mn[i].y; L[0] = L[16] = M[i].x; L[1] = L[17] = M[i].y; L[2] = L[18] = M[i].z; L[3] = L[19] = 1.; L[4] = L[5] = L[6] = L[7] = 0.; L[12] = L[13] = L[14] = L[15] = 0.; L[8] = x*M[i].x; L[9] = x*M[i].y; L[10] = x*M[i].z; L[11] = x; L[20] = y*M[i].x; L[21] = y*M[i].y; L[22] = y*M[i].z; L[23] = y; } cvMulTransposed( matL, &amp;_LL, 1 ); cvSVD( &amp;_LL, &amp;_LW, 0, &amp;_LV, CV_SVD_MODIFY_A + CV_SVD_V_T ); _RRt = cvMat( 3, 4, CV_64F, LV + 11*12 ); cvGetCols( &amp;_RRt, &amp;_RR, 0, 3 ); cvGetCol( &amp;_RRt, &amp;_tt, 3 ); if( cvDet(&amp;_RR) &lt; 0 ) cvScale( &amp;_RRt, &amp;_RRt, -1 ); sc = cvNorm(&amp;_RR); cvSVD( &amp;_RR, &amp;matW, &amp;matU, &amp;matV, CV_SVD_MODIFY_A + CV_SVD_U_T + CV_SVD_V_T ); cvGEMM( &amp;matU, &amp;matV, 1, 0, 0, &amp;matR, CV_GEMM_A_T ); cvScale( &amp;_tt, &amp;_t, cvNorm(&amp;matR)/sc ); cvRodrigues2( &amp;matR, &amp;_r ); } } cvReshape( matM, matM, 3, 1 ); cvReshape( _mn, _mn, 2, 1 ); // refine extrinsic parameters using iterative algorithm CvLevMarq solver( 6, count*2, cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,max_iter,FLT_EPSILON), true); cvCopy( &amp;_param, solver.param ); for(;;) { CvMat *matJ = 0, *_err = 0; const CvMat *__param = 0; bool proceed = solver.update( __param, matJ, _err ); cvCopy( __param, &amp;_param ); if( !proceed || !_err ) break; cvReshape( _err, _err, 2, 1 ); if( matJ ) { cvGetCols( matJ, &amp;_dpdr, 0, 3 ); cvGetCols( matJ, &amp;_dpdt, 3, 6 ); cvProjectPoints2( matM, &amp;_r, &amp;_t, &amp;matA, distCoeffs, _err, &amp;_dpdr, &amp;_dpdt, 0, 0, 0 ); } else { cvProjectPoints2( matM, &amp;_r, &amp;_t, &amp;matA, distCoeffs, _err, 0, 0, 0, 0, 0 ); } cvSub(_err, _m, _err); cvReshape( _err, _err, 1, 2*count ); } cvCopy( solver.param, &amp;_param ); _r = cvMat( rvec-&gt;rows, rvec-&gt;cols, CV_MAKETYPE(CV_64F,CV_MAT_CN(rvec-&gt;type)), param ); _t = cvMat( tvec-&gt;rows, tvec-&gt;cols, CV_MAKETYPE(CV_64F,CV_MAT_CN(tvec-&gt;type)), param + 3 ); cvConvert( &amp;_r, rvec ); cvConvert( &amp;_t, tvec ); } </code></pre> <p>I guess it is pretty complicated! :(</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload