gpt4 book ai didi

python opencv2 findHomography

转载 作者:太空宇宙 更新时间:2023-11-03 23:13:39 25 4
gpt4 key购买 nike

使用 opencv2 - 2.4.9 尝试使用 cv2.findHomography 计算单应矩阵时出现以下错误。我使用的值显然有问题,尤其是 rect_points 矩阵。如果我更改矩阵的值以使它们更小,则某些矩阵的计算会成功。

(Pdb) findHomography(pts_dst,pts_src)
(array([[ 1.80258009e+00, 1.55276411e+00, -7.76398173e+02],
[ -8.09994414e-01, 2.13295256e+00, -1.07909987e+02],
[ 5.79313440e-04, 7.57830547e-04, 1.00000000e+00]]), array([[1],
[1],
[1],
[1]], dtype=uint8))
(Pdb) findHomography(tc,pts_dst)
(array([[ 5.86310680e-01, -1.02457072e+00, 3.18000000e+02],
[ 2.73257186e-01, 4.37679421e-01, 2.56000000e+02],
[ -4.88292404e-04, -8.73786408e-04, 1.00000000e+00]]), array([[1],
[1],
[1],
[1]], dtype=uint8))
(Pdb) findHomography(rect_points/2,tc)
(array([[ 3.12565925e+00, -4.01560389e-01, -1.46710631e+02],
[ 6.46267255e-01, 3.94065399e-01, -7.32725203e+01],
[ -1.24144088e-02, 9.62934110e-04, 1.00000000e+00]]), array([[1],
[1],
[1],
[1]], dtype=uint8))
(Pdb) findHomography(rect_points-50,tc)
(array([[ 2.18971678e+00, -2.81317781e-01, -1.10139713e+02],
[ 4.52750009e-01, 2.76067079e-01, -6.62229708e+01],
[ -8.69705784e-03, 6.74594641e-04, 1.00000000e+00]]), array([[1],
[1],
[1],
[1]], dtype=uint8))
(Pdb) findHomography(rect_points,tc)
OpenCV Error: Assertion failed (npoints >= 0 && points2.checkVector(2) == npoints && points1.type() == points2.type()) in findHomography, file /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/modules/calib3d/src/fundam.cpp, line 1074
*** error: /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/modules/calib3d/src/fundam.cpp:1074: error: (-215) npoints >= 0 && points2.checkVector(2) == npoints && points1.type() == points2.type() in function findHomography



(Pdb) rect_points
array([[ 117., 180.],
[ 142., 139.],
[ 160., 314.],
[ 154., 468.]], dtype=float32)
(Pdb) tc
array([[ 0., 0.],
[ 255., 0.],
[ 255., 255.],
[ 0., 255.]], dtype=float32)
(Pdb)

(Pdb) pts_src
array([[ 141., 131.],
[ 480., 159.],
[ 493., 630.],
[ 64., 601.]], dtype=float32)
(Pdb) pts_dst
array([[ 318., 256.],
[ 534., 372.],
[ 316., 670.],
[ 73., 473.]], dtype=float32)
(Pdb)

最佳答案

与 cv2 FindHomography 相比,使用 cv 库 FindHomography 运行时没有错误。问题一定出在 cv2 v2.4.9

关于python opencv2 findHomography,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44357305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com