将三角形点与SFM和Python一起使用

2024-05-13 01:05:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试对多个视图使用内置的opencv函数TriangulatePoints:https://docs.opencv.org/3.4.4/d0/dbd/group__triangulation.html#ga211c855276b3084f3bbd8b2d9161dc74。在

在linux上使用python,有人有使用这个函数的经验吗?这个网站只有cpp的语法,在python中我不知道如何编写它。在

我的代码现在:

import cv2
import numpy as np
point_2D = np.array([[17.4485, 709.7993], [17.4382, 709.8409]])
Proj_Matrices = np.array([ [1037.5, -6.9927, -10.0190, -4780.7], [6.9747, 1043.3, -5.8867, -731.9206], [644.7895, 383.4982, -3231.1], [1036.937, -22.8371, -28.3254, -5607.7], [23.0587, 1043.1, 3.1815, -633.4485], [650.4355, 373.6, -15.3504, -3706.5] ])

OutputArray = np.zeros((3,2))
Points_3D = cv2.sfm.triangulatePoints(point_2D, Proj_Matrices, OutputArray)

但是,当我从终端运行它时,我得到了以下错误:

AttributeError: module 'cv2' has no attribute 'sfm.

在我的网站上用我的电脑安装了sfm。在

当我忽略sfm时,会出现以下错误:

AttributeError: module 'cv2' has no attribute 'sfm'

我想我得到了这个错误,因为机器认为我在尝试使用以前版本的三角点。在

opencv网站上有使用sfm的opencv代码示例,但它们都在cpp中。在

我想知道python中使用三角点(sfm)的语法是什么?即使在cpp中,我也不明白输出数组是如何作为函数的输入的?另外,如果有人知道如何修复我收到的sfm错误,将不胜感激。在

谢谢!在


Tags: 函数代码import网站错误np语法array