c++ - Using OpenCVs findTransformECC to find the affine transformation applied with OpenCVs warpAffine does not give the same warp matrix back like used -


i trying kind of selftest of opencvs implementation of function findtranfromecc (http://docs.opencv.org/3.0-beta/modules/video/doc/motion_analysis_and_object_tracking.html#findtransformecc ).

to create warp-matrix myself , affine transformation function warpaffine given opencv. after affine transform use input of affine transform , warped output in transfromecc function. hoped same matrix used in affine transform, bud sadly differs lot - completly different one.

in code example put @ end of post got following matrix making affine transform:

[0.850332161003909, 0.1778601204261232, 0]
[-0.06752637272097255, 0.3701713812908899, 712.799877929688]

but calculated matrix findtransformecc is:

[1.0151283, -0.0033983635, -5.6531301]
[-0.023056569, 1.038756, -8.7541409]

i compared eigen-values:

for doing affine transform:

[127021.1755113913]
[0]

calulated warp-matrix eigenvalues:

[2.945044]
[0]

does has made same experience or might causes error?

i appreciate everyones

point2f srctri[3]; point2f dsttri[3]; float scale = (float)1 / (float)255;  //matri first affine transform mat warp_mat(2, 3, cv_32fc1);  //matrix affine transform mat warp_mat2 = mat::eye(2, 3, cv_32fc1);   mat src, warp_dst, warp_rotate_dst;   //get image image class , convert 8 bit used  //findtransfromsecc this->demosaiceddestination.convertto(src, cv_8uc1, scale, 0);   //container warp destination warp_dst = mat::zeros(src.rows, src.cols, cv_8uc1);   //points warp matrix srctri[0] = point2f(0, 0); srctri[1] = point2f(src.cols - 1, 0); srctri[2] = point2f(0, src.rows - 1);  dsttri[0] = point2f(src.cols*0.0, src.rows*0.33); dsttri[1] = point2f(src.cols*0.85, src.rows*0.25); dsttri[2] = point2f(src.cols*0.15, src.rows*0.7);   //get affine transformation warp mat warp_mat = getaffinetransform(srctri, dsttri); //do affine transformation warpaffine(src, warp_dst, warp_mat, warp_dst.size());  //show affine transformation imshow("src", src); waitkey(0);  cout << "warp matrix used: " << warp_mat << endl; namedwindow("warped ", window_normal); imshow("warped to",warp_dst);  termcriteria criteria(termcriteria::count + termcriteria::eps, 2500, 1e-1); try{     this->cc = findtransformecc(warp_dst, src, warp_mat2, motion_affine, criteria); } catch (exception& e){     const char* err_msg = e.what();     cout << err_msg;     return false; }   //do affine transformation warpaffine(warp_dst, src, warp_mat2, src.size());   //show backwarded afine transform namedwindow("back warped transform", window_normal); imshow("back warped transform", src); waitkey(0);   //show calculated matrix, should same warp matrix used  cout << "calculated warp matrix 1 " << warp_mat2 << endl; 

inversing matrix given opencv function gave correct solution.


Comments