Pose of camera from the pose of marker

泪湿孤枕 提交于 2021-02-10 03:11:01

问题


I am currently working on a task to localize a vehicle using computer vision. I am using OpenCV with C++. I implemented ArUco marker to get the pose of the camera placed on the vehicle.

I used of the following function to estimate pose of the marker :

cv::aruco::estimatePoseSingleMarkers(markerCorners, markerLength, camMatrix, distCoeffs, rvecs,tvecs)

Later I found out that rvecs and tvecs are 1x1 arrays with 3 channels (openCVDataType=CV_8UC3).

Now, I get R(3x3) matrix from cv::Rodrigues function say it's Ri.

In order to get the pose of the camera w.r.t to marker, after a considerable amount of research I found out that the inverse transforms have to be taken. I got inverse if Ri.

Now to get inverse of translation vector it is just the multiplication of the above inverse with the translation vector (tvecs).

I am fairly new to c++ and my issues are:

  1. Is my approach correct in finding the pose of camera w.r.t marker?
  2. I am unable to change the tvecs into a mat object so that there is no multiplication error.

回答1:


Method estimatePoseSingleMarkers uses cv::solvePnP method within. That's why for camera pose estimation you need to perform next:

Mat R;
cv::Rodrigues(rvec, R); // calculate your object pose R matrix

camR = R.t();  // calculate your camera R matrix

Mat camRvec;
Rodrigues(R, camRvec); // calculate your camera rvec

Mat camTvec= -camR * tvec; // calculate your camera translation vector

It seems that it fits your guesses




回答2:


Method of Rodriguez provides you a rotation matrix. Make a 4*4 transformation matrix with the help of rotation matrix and translation matrix. Inversing the transformation matrix will provide the pose of the camera with respect to marker. For the equations, just google, it's quite simple and available. You need to extract rotation and translation from the inverse transformation matrix.



来源:https://stackoverflow.com/questions/51476702/pose-of-camera-from-the-pose-of-marker

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!