c++ - Two 3D point cloud transformation matrix -


i'm trying guess wich rigid transformation matrix between 2 3d points clouds. 2 points clouds ones:

  • keypoints kinect (kinect_keypoints).
  • keypoints 3d object (box) (object_keypoints).

i have tried 2 options:

[1]. implementation of algorithm find rigid transformation.

**1.calculate centroid of each point cloud.**  **2.center points according centroid.**  **3. calculate covariance matrix** cvsvd( &_h, _w, _u, _v,  cv_svd_u_t ); cvmatmul( _v,_u, &_r ); **4. calculate rotartion matrix using svd descomposition of covariance matrix**  float _tsrc[16] = { 1.f,0.f,0.f,0.f,     0.f,1.f,0.f,0.f,     0.f,0.f,1.f,0.f,     -_gc_src.x,-_gc_src.y,-_gc_src.z,1.f };  // 1: src points origin float _s[16] = { _scale,0.f,0.f,0.f,     0.f,_scale,0.f,0.f,     0.f,0.f,_scale,0.f,     0.f,0.f,0.f,1.f };  // 2: scale src points float _r_src_to_dst[16] = { _rdata[0],_rdata[3],_rdata[6],0.f,      _rdata[1],_rdata[4],_rdata[7],0.f,     _rdata[2],_rdata[5],_rdata[8],0.f,     0.f,0.f,0.f,1.f }; // 3: rotate scr points float _tdst[16] = { 1.f,0.f,0.f,0.f,      0.f,1.f,0.f,0.f,      0.f,0.f,1.f,0.f,      _gc_dst.x,_gc_dst.y,_gc_dst.z,1.f }; // 4: scr dst  // _tdst * _r_src_to_dst * _s * _tsrc mul_transform_mat( _s, _tsrc, rt ); mul_transform_mat( _r_src_to_dst, rt, rt ); mul_transform_mat( _tdst, rt, rt );        

[2]. use estimateaffine3d opencv.

        float _posetrans[12];         std::vector<cv::point3f> first, second;                      cv::mat aff(3,4,cv_64f, _posetrans);         std::vector<cv::point3f> first, second; (first-->kineckt_keypoints , second-->object_keypoints)         cv::estimateaffine3d( first, second, aff, inliers );          float _posetrans2[16];          (int i=0; i<12; ++i)         {             _posetrans2[i] = _posetrans[i];         }          _posetrans2[12] = 0.f;         _posetrans2[13] = 0.f;         _posetrans2[14] = 0.f;         _posetrans2[15] = 1.f; 

the problem in first 1 transformation not correct , in second one, if multiply kinect point cloud resultant matrix, values infinite.

is there solution of these options? or alternative one, apart pcl?

thank in advance.

edit: old post, answer might useful ...

your first approach can work in specific cases (ellipsoid point clouds or elongated shapes), not appropriate point clouds acquired kinect. , second approach, not familiar opencv function estimateaffine3d suspect assumes 2 input point clouds correspond same physical points, not case if used kinect point cloud (which contain noisy measurements) , points ideal 3d model (which perfect).

you mentioned aware of point cloud library (pcl) , not want use it. if possible, think might want reconsider this, because pcl more appropriate opencv want (check tutorial list, 1 of them covers exactly want do: aligning object templates point cloud).

however, here alternative solutions problem:

  1. if 2 point clouds correspond same physical points, second approach should work, can check out absolute orientation (e.g. matlab implementation)

  2. if 2 point clouds not correspond same physical points, want register (or align) them , can use either:

    • one of many variants of iterative closest point (icp) algorithm, if know approximately position of object. wikipedia entry

    • 3d feature points such 3d sift, 3d surf or narf feature points, if have no clue object's position.

again, these approaches implemented in pcl.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -