前提・実現したいこと
現在、pythonを用いて点群処理を行おうと思っています.
そこで始めに全点群から割合を決めて点群を間引くプログラムを
書いているのですが、点群をランダム抽出することができません.
発生している問題・エラーメッセージ
File "test2.py", line 18, in <module>
print(random.sample(data,points))
File "C:\Users\anaconda3\lib\random.py", line 317, in sample
raise TypeError("Population must be a sequence or set. For dicts, use list(d).")
TypeError: Population must be a sequence or set. For dicts, use list(d).
該当のソースコード
import numpy as np
import random
import math
data = np.loadtxt(fname="trackC_all.txt",delimiter=" ",skiprows=0,dtype="float",usecols=(0,1,2))
all_points = len(data)
print("点群の総数: ", all_points)
percent = int(input("点群を残す割合(%): "))
points = all_points * percent / 100
points = math.floor(points)
print("間引きして残った点群の総数: ",points)
print(random.sample(data,points))
試したこと
data=[[10 20 10][21 30 22]....[12 20 11]]
のようにリストの中にリストがあるため
random.sampleができないのだと考え、リストごと抽出できる方法を
探していたのですが、解決法を見つけることができませんでした.
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/04/27 09:50
2020/04/27 09:55
2020/04/27 10:23
2020/04/27 11:23
2020/04/27 13:21