- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在努力尝试正确地解释Essential矩阵中restorePose的结果。这基于How do I estimate positions of two cameras in OpenCV?中发布的原始代码
这是我正在使用的高级步骤:
1.在两个图像中检测ORB功能
2.使用BFMatcher匹配特征
3.在两个图像上查找findEssential
4. restorePose,即来自两个图像的R,T
5.使用R,T划分好特征(从restorePose中屏蔽),以创建3d点云(地标)
6.作为基本事实,我还从图像中提取国际象棋棋盘角,并使用上面计算的R,T对它们进行三角测量。棋盘角的良好平面结构表明R,T对于三角剖分而言是准确的。
7.绘制所有内容
import numpy as np
import cv2
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def plot_pose3_on_axes(axes, gRp, origin, axis_length=0.1):
"""Plot a 3D pose on given axis 'axes' with given 'axis_length'."""
# get rotation and translation (center)
#gRp = pose.rotation().matrix() # rotation from pose to global
#t = pose.translation()
#origin = np.array([t.x(), t.y(), t.z()])
# draw the camera axes
x_axis = origin + gRp[:, 0] * axis_length
line = np.append(origin, x_axis, axis=0)
axes.plot(line[:, 0], line[:, 1], line[:, 2], 'r-')
y_axis = origin + gRp[:, 1] * axis_length
line = np.append(origin, y_axis, axis=0)
axes.plot(line[:, 0], line[:, 1], line[:, 2], 'g-')
z_axis = origin + gRp[:, 2] * axis_length
line = np.append(origin, z_axis, axis=0)
axes.plot(line[:, 0], line[:, 1], line[:, 2], 'b-')
img1 = cv2.imread('/home/vik748/data/chess_board/GOPR1488.JPG',1) # queryImage
img2 = cv2.imread('/home/vik748/data/chess_board/GOPR1490.JPG',1)
fx = 3551.342810
fy = 3522.689669
cx = 2033.513326
cy = 1455.489194
K = np.float64([[fx, 0, cx],
[0, fy, cy],
[0, 0, 1]])
D = np.float64([-0.276796, 0.113400, -0.000349, -0.000469]);
print(K,D)
# Convert images to greyscale
gr1=cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY)
gr2=cv2.cvtColor(img2,cv2.COLOR_BGR2GRAY)
#Initiate ORB detector
detector = cv2.ORB_create(nfeatures=25000, edgeThreshold=15, patchSize=125, nlevels=32,
fastThreshold=20, scaleFactor=1.2, WTA_K=2,
scoreType=cv2.ORB_HARRIS_SCORE, firstLevel=0)
# find the keypoints and descriptors with ORB
kp1, des1 = detector.detectAndCompute(gr1,None)
kp2, des2 = detector.detectAndCompute(gr2,None)
print ("Points detected: ",len(kp1), " and ", len(kp2))
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(des1,des2)
kp1_match = np.array([kp1[mat.queryIdx].pt for mat in matches])
kp2_match = np.array([kp2[mat.trainIdx].pt for mat in matches])
kp1_match_ud = cv2.undistortPoints(np.expand_dims(kp1_match,axis=1),K,D)
kp2_match_ud = cv2.undistortPoints(np.expand_dims(kp2_match,axis=1),K,D)
E, mask_e = cv2.findEssentialMat(kp1_match_ud, kp2_match_ud, focal=1.0, pp=(0., 0.),
method=cv2.RANSAC, prob=0.999, threshold=0.001)
print ("Essential matrix: used ",np.sum(mask_e) ," of total ",len(matches),"matches")
points, R, t, mask_RP = cv2.recoverPose(E, kp1_match_ud, kp2_match_ud, mask=mask_e)
print("points:",points,"\trecover pose mask:",np.sum(mask_RP!=0))
print("R:",R,"t:",t.T)
bool_mask = mask_RP.astype(bool)
img_valid = cv2.drawMatches(gr1,kp1,gr2,kp2,matches, None,
matchColor=(0, 255, 0),
matchesMask=bool_mask.ravel().tolist(), flags=2)
plt.imshow(img_valid)
plt.show()
ret1, corners1 = cv2.findChessboardCorners(gr1, (16,9),None)
ret2, corners2 = cv2.findChessboardCorners(gr2, (16,9),None)
corners1_ud = cv2.undistortPoints(corners1,K,D)
corners2_ud = cv2.undistortPoints(corners2,K,D)
#Create 3 x 4 Homogenous Transform
Pose_1 = np.hstack((np.eye(3, 3), np.zeros((3, 1))))
print ("Pose_1: ", Pose_1)
Pose_2 = np.hstack((R, t))
print ("Pose_2: ", Pose_2)
# Points Given in N,1,2 array
landmarks_hom = cv2.triangulatePoints(Pose_1, Pose_2,
kp1_match_ud[mask_RP[:,0]==1],
kp2_match_ud[mask_RP[:,0]==1]).T
landmarks_hom_norm = landmarks_hom / landmarks_hom[:,-1][:,None]
landmarks = landmarks_hom_norm[:, :3]
corners_hom = cv2.triangulatePoints(Pose_1, Pose_2, corners1_ud, corners2_ud).T
corners_hom_norm = corners_hom / corners_hom[:,-1][:,None]
corners_12 = corners_hom_norm[:, :3]
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_aspect('equal') # important!
title = ax.set_title('3D Test')
ax.set_zlim3d(-5,10)
# Plot triangulated featues in Red
graph, = ax.plot(landmarks[:,0], landmarks[:,1], landmarks[:,2], linestyle="", marker="o",color='r')
# Plot triangulated chess board in Green
graph, = ax.plot(corners_12[:,0], corners_12[:,1], corners_12[:,2], linestyle="", marker=".",color='g')
# Plot pose 1
plot_pose3_on_axes(ax,np.eye(3),np.zeros(3)[np.newaxis], axis_length=0.5)
#Plot pose 2
plot_pose3_on_axes(ax, R, t.T, axis_length=1.0)
ax.set_zlim3d(-2,5)
ax.view_init(-70, -90)
plt.show()
最佳答案
我通过对旋转矩阵求逆来解决此问题,因为recoverPose
函数定义了点移动方向而不是摄像机移动方向的旋转和平移。有关更多信息,请参见this post。
关于opencv - 从OpenCV的Essential矩阵正确解释 'recoverPose'之后的姿势(旋转和翻译),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54486906/
我刚刚更新了 Web 要点,现在我没有语法突出显示或编译。在更改说明中,我可以读到 2.5 版中的“删除了 LESS/CoffeeScript 编辑器”,但是 less 的选项仍然存在?!。 什么?为
我在 VS 2013(更新 1)中安装了一个全新的 MVC 5.1 Web 应用程序项目,其中安装了 Web Essential 2013(截至今天的最新版本)。构建项目后,Web Essential
我找不到很多/任何关于 web essentials 2013 的此功能的文档。 Web Essentials Markdown 预览是否可以使用相对图像路径?另外,如何从一个 Markdown 文件
题记: 之前由SharpDevelop团队开发且用于SharpDevelop这个开源IDE中的重构插件“NR6Pack”改名为“Refactoring Essentials”,被Hanselman
在 W3C 跨源资源共享建议 (http://www.w3.org/TR/cors/#resource-requests) 的第 3 步中,它指出: If the resource supports
查看 Xamarin 基本要素并想知道 FileSystem 的目的是什么。 我一直在寻找可以立即为我异步加载和保存文件的东西。 它在我看来,可能是我不理解它给您的唯一功能是保存和加载文件的位置,并且
在查看有关保存 JWT token 的选项后,我选择了 Xamarin.Essentials Secure Storage。 问题是我的应用程序在尝试在存储中保存 token 时总是中断并出现以下错误
我在 Ivo Balbaert 所著的 Rust Essentials 一书中找到了获取变量内存位置的代码,在第 2 章中关于“堆栈和堆”的内容: let a = 32; let mut b = "s
当我编译我的 websolution 时,web essentials 从 less 文件中生成 css 文件。我总是遇到源控制冲突,因为 css 文件的输出不同。在队友的计算机上使用 vs2013/
我将在我的 CSS 中使用 .less。 根据我的理解,有不同的方式来使用 .less。 您可以预编译它,然后使用 .less 生成的 css 另一个正在使用下面的脚本: 这个 或 据我了解,
我已下载并安装了.vslx文件,该文件会导致Web要素成为VS 2012的一部分。 这可能是一个愚蠢的问题。 但是,如何从vs.中删除Webessentials?我在VS 2012中找不到这样的选项。
这是我的背景。 我在工作时有一个小屏幕 Typescript 预览屏幕不记得它以前的大小,而且每次打开 TS 文件时都要折叠它很烦人 Web Essentials 新版本没有我们可以控制任何设置的 T
我正在开发一个使用 Web Essentials 来捆绑和缩小脚本文件的项目。 它运行良好,当我保存对脚本文件的更改时,Web Essentials 会运行。我们目前有几个开发人员参与该项目,每次从源
我们使用此Visual Studio扩展,但也希望在未检入生成的捆绑文件的情况下在CI服务器上使用它。是否没有用于此的命令行工具? 想知道其余的Web Essentials社区是如何做到的吗?当然其他
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
我试图理解web essential's Go To Definition feature statement : Go To Definition is built in to VS2012 and
我尝试修改Essential JS基于 ejgantt 的项目跟踪器示例组件: $("#gantt").ejGantt({ dataSource: projectData,
有 2 个文件,我想将变量样式表导入第二个文件,但在第一种情况下,我在预览模式下遇到不正确的语法错误,在第二种情况下,我得到未声明的变量 错误。无论如何,两种情况都编译正确。 预览模式错误的第一种情况
有 2 个文件,我想将变量样式表导入第二个文件,但在第一种情况下,我在预览模式下遇到不正确的语法错误,在第二种情况下,我得到未声明的变量 错误。无论如何,两种情况都编译正确。 预览模式错误的第一种情况
我正在借助书 Essential SQLAlchemy 来学习 SQLAlchemy . 其中一个示例对于我想要学习的内容至关重要 - 添加相关对象。我就是无法让它发挥作用。我希望这个社区可以帮助确定
我是一名优秀的程序员,十分优秀!