为什么我的输出参数保持不变?

2024-04-19 21:27:45 发布

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

我第一次在这个论坛上提出这个问题,向大家致意。在

我一直在尝试使用estimateAffine3D,我似乎没有得到任何关于变量的结果。在

重现我的问题的(几乎)最短的代码是:

import cv2 as cv
import numpy as np

X=array([[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]])
# the eight vertices of a unit cube
Y=array([[0,0,0],[0,0,1],[0,1,0],[0,1,1],[2,0,0],[2,0,1],[2,1,0],[2,1,1]])
# the same cube scaled by 2 in the X direction (and no longer a cube)

# create the output variables and fill them with recognizable values:
MyAffine=array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 9]])
MyInLi=array([7,3,7])

# now fire estimateAffine3D:
cv.estimateAffine3D(src=X,dst=Y,out=MyAffine,inliers=MyInLi)

# NB I also tried this without the formal parameter names:
# cv.estimateAffine3D(X,Y,MyAffine,MyInLi)

# Now see what gives:
print "MyAffine=", MyAffine
print "MyInLi=", MyInLi

两个数组,在代码末尾打印出来, 包含与创建它们时使用的相同占位符值。在

我花了很多时间在google上搜索类似问题的现有答案,但是关于estimateAffine3D的那些问题集中在它确实返回一些值(如果不是用户期望的值)的情况下,或者它抛出错误的情况—这不是我的情况。在

我也一直在讨论Python如何传递参数,但我所理解的是,它通过了它们 > e> EEM >从我所知道的任何东西(C++,一个小Pascal,和几个世纪以前,Basic和Fortran)。我无法理解Python的方式可能是我陷入困境的原因,但是我应该做些什么呢?在

提前感谢你的开悟。在


Tags: andthe代码importas情况arraycv2