簡體   English   中英

python opencv2 findHomography

[英]python opencv2 findHomography

使用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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM