gpt4 book ai didi

python - 使用 Python 转换 OpenCV triangulatePoints 输出以用于 perspectiveTransform

转载 作者:太空宇宙 更新时间:2023-11-03 21:54:12 29 4
gpt4 key购买 nike

cv2.triangulatePoints 的输出被指定为齐次坐标中重建点的 4xN 数组。

我想将此输出用作 cv2.perspectiveTransform 的 src 数组输入。 src指定为双 channel 或三 channel float 组。

操作 triangulatePoints 输出数组使其适合 perspectiveTransform 的正确方法是什么?

最佳答案

这帮助我弄明白了:

http://answers.opencv.org/question/252/cv2perspectivetransform-with-python/

我是这样实现的:

    Tpoints1 = cv2.triangulatePoints(P_1, P_2, normRshp1, normRshp2)         
#Grab the first three columns from the results to make a 3-N array
Tpt1 = np.array([Tpoints1[0],Tpoints1[1],Tpoints1[2]])
#Reshape to make a N-3 array
Tpt1 = Tpt1.reshape(-1,3)
#Make an array from the array resulting in [1,N,3]
Tpt1 = np.array([Tpt1])
#Reshape camera matrix to a 4x4 for input into perspectiveTransform
#we'll just add zeros and a one to the last row.
# from the TestTriangualtion function @,
#https://github.com/MasteringOpenCV/code/blob/master/Chapter4_StructureFromMotion/FindCameraMatrices.cpp
P_24x4 = resize(P_2,(4,4))
P_24x4[3,0] = 0
P_24x4[3,1] = 0
P_24x4[3,2] = 0
P_24x4[3,3] = 1
Tpoints1_projected = cv2.perspectiveTransform(Tpt1, P_24x4)

关于python - 使用 Python 转换 OpenCV triangulatePoints 输出以用于 perspectiveTransform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19385209/

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