Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.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根据阈值使用PhotoScan过滤点云-需要基本Python帮助_Python_Python 3.x - Fatal编程技术网

Python根据阈值使用PhotoScan过滤点云-需要基本Python帮助

Python根据阈值使用PhotoScan过滤点云-需要基本Python帮助,python,python-3.x,Python,Python 3.x,我正试图用Python实现一个过滤器,对PhotoScan生成的点云上的点进行排序。PhotoScan是一个摄影测量软件,它的开发目的是用户友好,但也允许通过 贝娄是我的代码到目前为止,我很肯定有更好的方式来写它,因为我错过了一些东西。代码在PhotoScan中运行 目标: 一次选择和删除10%的点,误差在50到10的定义范围内。当一次选择并移除10%的初始步骤完成时,也移除误差范围小于总误差10%的任何点。在每个点移除后,应立即执行优化程序。当没有可选择的点或可选择的点少于当前总点的1%且不值

我正试图用Python实现一个过滤器,对PhotoScan生成的点云上的点进行排序。PhotoScan是一个摄影测量软件,它的开发目的是用户友好,但也允许通过

贝娄是我的代码到目前为止,我很肯定有更好的方式来写它,因为我错过了一些东西。代码在PhotoScan中运行

目标: 一次选择和删除10%的点,误差在50到10的定义范围内。当一次选择并移除10%的初始步骤完成时,也移除误差范围小于总误差10%的任何点。在每个点移除后,应立即执行优化程序。当没有可选择的点或可选择的点少于当前总点的1%且不值得删除时,应停止


画出来以便更好地理解:

施工中的实际代码(3次更新-详情见下文):
更新2:施工中代码的变更 通过遵循另一篇关于这个主题的文章的指导,我们从一开始就重新启动了de for循环。现在必须改进范围或修改isclose()以获得更多值

restartLoop = True
while restartLoop:
    restartLoop = False
    for i in range(0, 10):
        if condition:
            restartLoop = True
            break

更新3:实现所列目标的代码结构:
# using float with range and that by setting i = 1 it steps 0.1 at a time
def precrange(a, b, i):
    if a < b:
        p = 10**i
        sr = a*p
        er = (b*p) + 1
        p = float(p)
        return map(lambda x: x/p, range(sr, er))
    else:
        p = 10**i
        sr = b*p
        er = (a*p) + 1
        p = float(p)
        return map(lambda x: x/p, range(sr, er))

# some code
f_ReconstUncert = precrange(50, 20, 1)
"""
Determine if x is close to y:
    x relates to nselected variable
    y to p10 variable

math.isclose() Return True if the values a and b are close to each other and
False otherwise

var is the tolerance here setted as a relative tolerance:
rel_tol is the relative tolerance – it is the maximum allowed difference
between a and b, relative to the larger absolute value of a or b. For example,
to set a tolerance of 5%, pass rel_tol=0.05. The default tolerance is 1e-09,
which assures that the two values are the same within about 9 decimal digits.
rel_tol must be greater than zero.

"""


def test_threshold(x, y, var):
    if math.isclose(x, y, rel_tol=var):  # if variables are close return True
        return True
    else:
        False

# some code

if test_threshold(nselected, p10, 0.1):
    # if true then a valid threshold is found
    # some code
restartLoop = True
while restartLoop:
    restartLoop = False
    for i in range(0, 10):
        if condition:
            restartLoop = True
            break
threshold = range(0, 11, 1)
listx = []
for i in threshold:
    listx.append(i)

restart = 0
restartLoop = True
while restartLoop:
    restartLoop = False
    for idx, i in enumerate(listx):
        print("do something as printing i:", i)

        if i > 5:  # if this condition restart loop
            print("found value for condition: ", i)
            del listx[idx]
            restartLoop = True
            print("RESTARTING LOOP\n")
            restart += 1
            break  # break inner while and restart for loop
        else:
            # continue if the inner loop wasn't broken
            continue
    else:
        continue

print("restart - outer while", restart)