python中tree 100 6_Python spatial.KDTree方法代码示例

本文详述了Python中scipy.spatial.KDTree模块的多种应用场景,包括点云注册、性能基准测试、数据索引构建、数据查询等。通过多个代码示例,展示了KDTree如何用于寻找最近邻、构建索引、三角剖分等问题,适用于机器学习、数据分析等领域。
摘要由CSDN通过智能技术生成

本文整理汇总了Python中scipy.spatial.KDTree方法的典型用法代码示例。如果您正苦于以下问题:Python spatial.KDTree方法的具体用法?Python spatial.KDTree怎么用?Python spatial.KDTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块scipy.spatial的用法示例。

在下文中一共展示了spatial.KDTree方法的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: generate_icp_results

​点赞 6

# 需要导入模块: from scipy import spatial [as 别名]

# 或者: from scipy.spatial import KDTree [as 别名]

def generate_icp_results(self, gt_pose):

from icp import icp_test

from scipy.spatial import KDTree

M_given = self.templates[self.template_idx,:,:]

S_given = helper.apply_transformation(M_given.reshape((1,-1,3)), gt_pose)[0]

# S_given = S_given + np.random.normal(0,1,S_given.shape)# Noisy Data

M_given = M_given[0:self.NUM_POINT,:]# template data

S_given = S_given[0:self.NUM_POINT,:]# source data

tree_M = KDTree(M_given)

tree_M_sampled = KDTree(M_given[0:100,:])

final_pose, model_data, sensor_data, predicted_data, title, _, _ = icp_test(S_given[0:100,:], M_given, tree_M, M_given[0:100,:], tree_M_sampled, S_given, gt_pose.reshape((1,6)), self.MAX_LOOPS, self.ftol)

self.find_errors(gt_pose, final_pose)

helper.display_three_clouds(model_data, sensor_data, predicted_data, title)

开发者ID:vinits5,项目名称:pointnet-registration-framework,代码行数:19,

示例2: bench_build

​点赞 6

# 需要导入模块: from scipy import spatial [as 别名]

# 或者: from scipy.spatial import KDTree [as 别名]

def bench_build(self):

print()

print(' Constructing kd-tree')

print('=====================================')

print(' dim | # points | KDTree | cKDTree ')

for (m, n, repeat) in [(3,10000,3), (8,10000,3), (16,10000,3)]:

print('%4s | %7s ' % (m, n), end=' ')

sys.stdout.flush()

data = np.concatenate((np.random.randn(n//2,m),

np.random.randn(n-n//2,m)+np.ones(m)))

print('| %6.3fs ' % (measure('T1 = KDTree(data)', repeat) / repeat), end=' ')

sys.stdout.flush()

print('| %6.3fs' % (measure('T2 = cKDTree(data)', repeat) / repeat), end=' ')

sys.stdout.flush()

print('')

开发者ID:ktraunmueller,项目名称:Computable,代码行数:20,

示例3: setUp

​点赞 6

# 需要导入模块: from scipy import spatial [as 别名]

# 或者: from scipy.spatial import KDTree [as 别名]

def setUp(self):

self.data = np.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]])

self.kdtree = KDTree(self.data)

self.n = self.kdtree.n

self.m = self.kdtree.m

np.random.seed(1234)

self.x = np.random.randn(3)

self.d = 0.5

self.k = 4

开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,

示例4: test_onetree_query

​点赞 6

# 需要导入模块: from scipy import spatial [as 别名]

# 或者: from scipy.spatial import KDTree [as 别名]

def test_onetree_query():

np.random.seed(0)

n = 50

k = 4

points = np.random.randn(n,k)

T = KDTree(points)

yield check_onetree_query, T, 0.1

points = np.random.randn(3*n,k)

points[:n] *= 0.001

points[n:2*n] += 2

T = KDTree(points)

yield check_onetree_query, T, 0.1

yield check_onetree_query, T, 0.001

yield check_onetree_query, T, 0.00001

yield check_onetree_query, T, 1e-6

开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,

示例5: exact_full_marker_data

​点赞 6

# 需要导入模块: from scipy import spatial [as 别名]

# 或者: from scipy.spatial import KDTree [as 别名]

def exact_full_marker_data(csv_path, marker_pkl):

all_data_arr = np.genfromtxt(csv_path, delimiter=",", skip_header=1)

marker_jdcs_collection = cPickle.load(open(marker_pkl[0], "rb"))

tmp_list = list()

for jdc in marker_jdcs_collection:

tmp_list.extend(jdc)

marker_pcd_arr = np.array(tmp_list)

tree = spatial.KDTree(all_data_arr[:, :3])

marker_full_data_ls = []

for i in xrange(marker_pcd_arr.shape[0]):

ret = tree.query(marker_pcd_arr[i])

marker_full_data_ls.append(all_data_arr[ret[1]])

marker_full_data_arr = np.array(marker_full_data_ls)

return marker_full_data_arr

# get the Hessian normal form of 3D plane

开发者ID:mfxox,项目名称:ILCC,代码行数:21,

示例6: build_index

​点赞 6

# 需要导入模块: from scipy import spatial [as 别名]

# 或者: from scipy.spatial import KDTree [as 别名]

def build_index(self):

midpoints = []

self.index = {}

for ct, fset in enumerate(self.sets.values()):

mp = []

for vr in self.explanatory_variables:

mp.append(fset.sets[vr.name].centroid)

midpoints.append(mp)

self.index[ct] = fset.name

import sys

sys.setrecursionlimit(100000)

self.kdtree = KDTree(midpoints)

sys.setrecursionlimit(1000)

开发者ID:PYFTS,项目名称:pyFTS,代码行数:21,

示例7: build_index

​点赞 6

# 需要导入模块: from scipy import spatial [as 别名]

# 或者: from scipy.spatial

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值