Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python转换OpenCV triangulatePoints输出以用于透视变换_Python_Opencv_Numpy - Fatal编程技术网

使用Python转换OpenCV triangulatePoints输出以用于透视变换

使用Python转换OpenCV triangulatePoints输出以用于透视变换,python,opencv,numpy,Python,Opencv,Numpy,cv2.triangulatePoints的输出指定为齐次坐标中重建点的4xN数组 我想将此输出用作cv2.perspectiveTransform的src数组输入。src被指定为两通道或三通道浮点数组 操作triangulatePoints输出数组以使其适合perspectiveTransform的正确方法是什么?这帮助我找到了答案: 下面是我如何实现它的: Tpoints1 = cv2.triangulatePoints(P_1, P_2, normRshp1, normRshp2

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

我想将此输出用作cv2.perspectiveTransform的src数组输入。src被指定为两通道或三通道浮点数组


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

这帮助我找到了答案:

下面是我如何实现它的:

    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)