【问题标题】:Extracting tuple indices提取元组索引
【发布时间】:2010-12-26 17:10:57
【问题描述】:

我最近接触到了 kinect。我正在使用 python 包装器来玩。现在有 2 个函数可以给出特定帧的深度和 RGB 值。我希望提取所有深度值大于'd'的rgb值

(depth,_) = sync_get_depth()
(rgb,_) = sync_get_video()  

我遍历每个深度值,然后找出索引并将其与 rgb 一起使用。有没有一种简单的方法可以做到这一点?

【问题讨论】:

    标签: python kinect


    【解决方案1】:

    我不知道 Python kinect 包装器,所以我不能告诉你使用哪些库函数。但是你应该看看zip 函数:

    depths = [0, 1, 2, 3, 4]
    colors = ['a', 'b', 'c', 'd', 'e']
    
    # Colors with an even depth
    [color for depth, color in zip(depths, colors) if depth % 2]
    

    给定一些可迭代对象,zip 返回包含每个元素的连续元素的元组。

    【讨论】:

    • 它给了我一个错误,说 ValueError:具有多个元素的数组的真值是不明确的。使用 a.any() 或 a.all()
    • 我用了for i range(x): for j in range(y): if depth[i,j] > 500: final_color[i,j] = depth[i,j],但是花了很多时间
    猜你喜欢
    • 1970-01-01
    • 2018-12-24
    • 2015-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    相关资源
    最近更新 更多