使用外部参数获取相机的相对位置,但 z 轴不面向相机
对象:我正在尝试通过校准获取两个相机的相对位置。
我正在使用 openCV 来实现这个目标。
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
if ret == True:
corners2 = cv2.cornerSubPix(cam1_img,corners,(11,11),(-1,-1), criteria)
# Find the rotation and translation vectors.
ret, rvecs, tvecs = cv2.solvePnP(objp, corners2, mtx, dist)
# Project 3D points to image plane
imgpts, jac = cv2.projectPoints(axisBoxes, rvecs, tvecs, mtx, dist)
img = drawBoxes(cam1_img,corners2,imgpts)
cv2.imwrite(f'result_img.jpg',img)
这就是我获得 rvecs、tvecs(旋转和平移向量)结果的方法 我尝试用这个绘制结果
R, _ = cv2.Rodrigues(rvecs)
offset = tvecs.T
R2, _ = cv2.Rodrigues(rvecs2)
offset2 = tvecs2.T
ax = pr.plot_basis(ax)
ax = pr.plot_basis(ax,R,offset)
ax = pr.plot_basis(ax,R2,offset2)
一些正面(蓝线)如何不面向原点基础
所以我尝试将相机位置与z轴旋转180度角。
R->[[ 0.287 -0.958 0.017]
[ 0.365 0.125 0.923]
[-0.886 -0.259 0.385]]
offset->[[ 3.182 12.088 62.537]]
我的旋转和偏移矢量如下所示。
- 为什么相机前端(蓝线)没有面向原点基准?
Object: I'm trying to get the relative position of the two camera's with calibration.
I'm using openCV to achieve this goal.
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
if ret == True:
corners2 = cv2.cornerSubPix(cam1_img,corners,(11,11),(-1,-1), criteria)
# Find the rotation and translation vectors.
ret, rvecs, tvecs = cv2.solvePnP(objp, corners2, mtx, dist)
# Project 3D points to image plane
imgpts, jac = cv2.projectPoints(axisBoxes, rvecs, tvecs, mtx, dist)
img = drawBoxes(cam1_img,corners2,imgpts)
cv2.imwrite(f'result_img.jpg',img)
This is how I get the result of the rvecs, tvecs(rotation and translation vectors)
I try to draw the result with this
R, _ = cv2.Rodrigues(rvecs)
offset = tvecs.T
R2, _ = cv2.Rodrigues(rvecs2)
offset2 = tvecs2.T
ax = pr.plot_basis(ax)
ax = pr.plot_basis(ax,R,offset)
ax = pr.plot_basis(ax,R2,offset2)
Some how the front(blue line) is not facing to the origin basis
so I try to rotate the camera position with z-axis with 180 degree of angle.
R->[[ 0.287 -0.958 0.017]
[ 0.365 0.125 0.923]
[-0.886 -0.259 0.385]]
offset->[[ 3.182 12.088 62.537]]
My Rotation and offset vector looks like this.
- why the camera front(blue line) is not facing to the origin basis?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的是方形棋盘图案,由于它是对称的,因此具有 90 度的模糊度,即如果您将图案旋转 90 度,它将在相机中显示完全相同。因此,请使用具有偶数和奇数行和列的棋盘图案。您可以查看此页面以生成所需的校准图案。
https://docs.opencv.org/4.x/da/ d0d/tutorial_camera_calibration_pattern.html
You are using a square checker board pattern and since it is symmetric it has an ambiguity of 90 degree i.e. if you rotate the pattern by 90 degree it will appear exactly the same to the camera. So use a checker board pattern with even and odd number of rows and cols. You can have a look at this page to generate the required calibration pattern.
https://docs.opencv.org/4.x/da/d0d/tutorial_camera_calibration_pattern.html