- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我尝试纠正图像和图像上的一些点。纠正图像效果很好(这部分代码不是我的):
(mapx, mapy) = cv2.initUndistortRectifyMap(camera_matrix,dist_coefs,np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]),newCameraMatrix,(int(resolution*w), int(resolution*h)), cv2.CV_32FC1)
RectImg = cv2.remap(img, mapx,mapy,cv2.INTER_LINEAR )
但是当我用 undistortPoints 和相同的参数纠正这些点时,我得到(在我看来)错误的坐标。
point_file = np.loadtxt(fn)
point_matrix = np.zeros(shape=(nr_points,1,2))
# fill Pointfile in n x 1 x 2-Matrix
for each in range(0, nr_points):
point_matrix[each][0][0] = point_file[each][0]
point_matrix[each][0][1] = point_file[each][1]
point_matrix_new = cv2.undistortPoints(point_matrix, newCameraMatrix, dist_coefs)
这些是我正在使用的参数(newCameraMatrix 和 dist_coefs):
[[ 4.93906295e+02 0.00000000e+00 1.24539714e+03]
[ 0.00000000e+00 4.92616567e+02 1.03814593e+03]
[ 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
[ 5.93179211e-01 3.59577119e-02 -3.34062329e-05 -8.92301489e-05
-5.27895858e-04 9.28762999e-01 1.46636733e-01 0.00000000e+00]
我也不确定实际输出是什么。结果值是图像坐标还是传感器坐标,单位是什么?我只能找到 cv ( http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html) 的 undistortPoints 文档,但找不到 cv2 的文档。
示例(图像尺寸 = 2448 x 2048 像素/传感器尺寸 = 8.6 x 6.6 毫米
输入(点矩阵):
[[[ 0. 0.]]
[[ 2448. 0.]]
[[ 0. 2048.]]
[[ 2448. 2048.]]
[[ 1224. 1024.]]]
输出(point_matrix_new):
[[[-6.49236118 -5.42726306]]
[[ 6.39989444 -5.5358653 ]]
[[-6.50237385 5.28935346]]
[[ 6.58981334 5.54673511]]
[[-0.04336093 -0.02874159]]]
感谢您的帮助!
最佳答案
所以我发现了我的错误:我必须像在 cv2.initUndistortRectifyMap 中那样在 cv2.undistortPoints 中使用旧的和新的相机矩阵。
为了更正它,我只使用了这段代码:
point_matrix_new = cv2.undistortPoints(point_matrix,camera_matrix,dist_coefs,P=newCameraMatrix)
关于python - 带有 Python 错误结果的 OpenCV (cv2) 中的 undistortPoints,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33040362/
我有一个 (x,y) 点、一个 3x3 相机矩阵和 4 个失真系数,我想得到未失真的点。我的代码看起来像这样...... double distorted_point_x = 10; double_d
我使用 openCV 函数 projectPoints() 来旋转、平移和投影一组 3D 点,并使用 solvePnp() 来找到这个旋转和平移。当镜头畸变系数全部为零时,这很有效,否则就会失败。完全
我正在使用 OpenCV 的失真模型进行一些测试。基本上我所做的是,实现失真方程并查看 cv::undistortPoints 函数是否给出这些方程的反函数。我意识到 cv::undistortPoi
我试图理解 OpenCV 的 cv::undisortPoints() 迭代逼近算法背后的逻辑。 实现可在以下位置获得: https://github.com/Itseez/opencv/blob/m
我正在编写我的相机校准算法,遇到以下困难。 给定针孔相机模型,则通过以下公式对径向变形进行建模 其中x,y是理想的标准化图像坐标,x_head是变形后x的坐标。 问题是如何为逆失真函数找到k1,k2,
我正在尝试使用 OpenCV Python 中的结构光对来自投影仪和相机的点进行三角测量。在这个过程中,我有一个在相机和投影仪之间一对一匹配的元组列表。我将其传递给 cv2.undistortedPo
我试图通过使用带有两个摄像头的 OpenCV 2.3.1 来确定两个对象之间的距离,但无法计算对象的对象点(OCV 2.3.1、MSVC++、Windows 7)。我认为这是因为在计算视差之前没有对图
我正在尝试使用 OpenCV 的“取消扭曲点”方法取消扭曲图像的某些点,但没有成功。 这些将是我的无失真系数 optic_camera_matrix: [[710.52285, 0.0,
我正在尝试找到捕获同一场景的两个摄像机(或者实际上是一个移动摄像机)之间的欧氏变换,其中校准数据 K(内部参数)和 d(失真系数)是已知的。我通过提取特征点、匹配它们并使用最佳匹配作为对应来做到这一点
为了更广泛的受众,我在这里重新发布了我在 answers.opencv.org 上提出的问题 TL;DR:传递给 undistortPoints、findEssentialMat 和 recoverP
我一直在使用 opencv,但我似乎无法让 undistortPoints 工作。它返回的矩阵只有 NaN 值。 //newKeyPoints is std::vector, and it's
为了测试,我生成了一个网格图像作为矩阵,并再次将网格点作为点数组: 这表示“扭曲”的相机图像以及一些特征点。当我现在取消扭曲图像和网格点时,我得到以下结果: (请注意,“失真”图像是直的而“未失真”图
根据我的理解,undistortPoints 在扭曲图像上获取一组点,并计算它们的坐标在同一图像的未扭曲版本上的位置。同样,projectPoints 将一组对象坐标映射到它们对应的图像坐标。 但是,
我正在尝试获取空间中几个点的 3D 坐标,但我从 undistortPoints() 和 triangulatePoints() 都得到了奇怪的结果。 由于两个相机的分辨率不同,我分别校准,得到0,3
我尝试纠正图像和图像上的一些点。纠正图像效果很好(这部分代码不是我的): (mapx, mapy) = cv2.initUndistortRectifyMap(camera_matrix,dist_c
我在格式化要传递给 undistortPoints (opencv 2.4.1) 的 x,y 点列表时遇到问题。 错误消息是特定于 C++ 的,并提示点数组不是 CV_32FC2 类型。难道我不能传入
我是一名优秀的程序员,十分优秀!