使用外部参数获取相机的相对位置,但 z 轴不面向相机

发布于 2025-01-16 15:07:49 字数 1231 浏览 2 评论 0原文

对象:我正在尝试通过校准获取两个相机的相对位置。
我正在使用 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]]

我的旋转和偏移矢量如下所示。

  1. 为什么相机前端(蓝线)没有面向原点基准?

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)

Then the result is as below.
enter image description here

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.

  1. why the camera front(blue line) is not facing to the origin basis?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆で 2025-01-23 15:07:49

您使用的是方形棋盘图案,由于它是对称的,因此具有 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文