[英]How can I find the angle between two chessboard planes?
我有兩個用solvePnp
獲得的棋盤姿勢:
Mat rotationVector1, translationVector1;
solvePnP(chess1WorldPoints, chess1ImagePoints, intrinsicMatrix, distortCoefficients, rotationVector1, translationVector1);
Mat rotationVector2, translationVector2;
solvePnP(chess2WorldPoints, chess2ImagePoints, intrinsicMatrix, distortCoefficients, rotationVector2, translationVector2);
如何檢查姿勢的平面是否平行,或找到這些平面之間的角度?
更多信息
我嘗試獲取歐拉角並計算每個alpha,beta和gamma之間的差,但這僅告訴我我認為的每個軸的相對旋轉:
Vec3d eulerAnglesPose1;
Mat rotationMatrix1;
Rodrigues(rotationVector1, rotationMatrix1);
getEulerAngles(rotationMatrix1, eulerAngles1);
Vec3d eulerAnglesPose2;
Mat rotationMatrix2;
Rodrigues(rotationVector2, rotationMatrix2);
getEulerAngles(rotationMatrix2, eulerAngles2);
我使用了Camera Rotation SolvePnp的getEulerAngles
實現:
void getEulerAngles(Mat &rotCamerMatrix, Vec3d &eulerAngles)
{
Mat cameraMatrix, rotMatrix, transVect, rotMatrixX, rotMatrixY, rotMatrixZ;
double* _r = rotCamerMatrix.ptr<double>();
double projMatrix[12] =
{
_r[0],_r[1],_r[2],0,
_r[3],_r[4],_r[5],0,
_r[6],_r[7],_r[8],0
};
decomposeProjectionMatrix(Mat(3, 4, CV_64FC1, projMatrix), cameraMatrix, rotMatrix, transVect, rotMatrixX, rotMatrixY, rotMatrixZ, eulerAngles);
}
編輯
在我的情況下,旋轉-平移對(R,T)給出了相機位於(0,0,0)的坐標系(相機坐標系)與其中(0,0,0)的坐標系之間的對應關系是我在solvePnp(世界坐標系)的前兩個參數中定義的。 所以我有兩個相對於同一相機坐標系的世界坐標系。 如果我可以從協調轉換。 系統2進行協調。 系統1我可以對每個平面使用Z = 0平面來查找法線並解決我的問題。
我認為例如從協調轉換。 系統2到相機系統的操作應類似於以下內容 :
Rinv = R' (just the transpose as it's a rotation matrix)
Tinv = -Rinv * T (T is 3x1 column vector)
然后,如果Pw = [XYZ]是世界坐標系中的一個點。 系統2我可以通過以下方式獲取其相機系統坐標:
Pc = [ Rinv Tinv] * [X Y Z 1] transposed.
Pc looks like [a b c d]
再次遵循相同的邏輯,我可以獲得相對於坐標的Pc坐標。 系統1:
Pw1 = [ R1 T1] * Pc
我應該規范化Pc還是只在最后規范化Pw1?
我在此OpenCV演示中找到了如何在坐標系之間轉換點。
“演示3:從攝影機位移開始的同形像術”(從標題右到代碼的第一行的部分)中的解釋說明了如何使用矩陣乘法在坐標系之間進行轉換。 我只需要將其應用於我的情況(我擁有C M O1和C M O2,並且需要找到O1 M O2 )。
這樣,我可以在同一坐標中獲得兩架飛機。 系統,獲取它們的法線並找到它們之間的角度。
它還有助於認識到外部矩陣[RT]轉換了來自世界坐標的3D點。 相機坐標系。 系統(相機位於(0,0,0)),而不是相反。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.