ShapeNetDataset
- 讀取synsetoffset2category.txt文件。查看分類種類和對(duì)應(yīng)文件夾名存放到字典
self.cat
中以及其鍵值翻轉(zhuǎn)版本self.id2cat
睬捶。
- 讀取train_test_split/shuffled_{}_file_list.json的json文件黔宛。創(chuàng)建
self.meta
以類別為key,其value為list擒贸。list中為對(duì)應(yīng)文件夾下points和points_label
中同id的標(biāo)記文件地址元組臀晃。用meta
每個(gè)id的點(diǎn)云和分割標(biāo)注文件和對(duì)應(yīng)點(diǎn)云類別組成元組存入list中叫self.datapath
。此外讀取../misc/num_seg_classes.txt
將類別和其序號(hào)重新排序存入seg_classes酗宋。num_seg_classes為每個(gè)類別應(yīng)該分隔成哪幾種积仗。
- 索引疆拘,大概會(huì)說明如何把點(diǎn)云數(shù)據(jù)轉(zhuǎn)換成網(wǎng)絡(luò)可以識(shí)別的數(shù)據(jù)蜕猫。
point_set = np.loadtxt(fn[1]).astype(np.float32)
對(duì)有排列規(guī)則的txt文件讀取為numpy的array。choice
是對(duì)point_set進(jìn)行隨機(jī)采樣npoints
個(gè)點(diǎn)后point_set = point_set[choice, :]
重新組成point_set哎迄,注意這里的點(diǎn)的個(gè)數(shù)影響推斷的精度回右。point_set = point_set - np.expand_dims(np.mean(point_set, axis=0), 0)
對(duì)點(diǎn)云數(shù)據(jù)中心化隆圆。dist = np.max(np.sqrt(np.sum(point_set ** 2, axis=1)), 0)point_set = point_set / dist # scale
進(jìn)行坐標(biāo)歸一化。
用自定義點(diǎn)云信息轉(zhuǎn)換為網(wǎng)絡(luò)輸入的步驟(分類任務(wù)中)
# 重采樣致2500個(gè)點(diǎn)
choice = np.random.choice(len(seg), self.npoints, replace=True)
point_set = point_set[choice, :]
# 中心化
point_set = point_set - np.expand_dims(np.mean(point_set, axis=0), 0) # center
# 歸一化
dist = np.max(np.sqrt(np.sum(point_set ** 2, axis=1)), 0)
point_set = point_set / dist # scale
# 轉(zhuǎn)換為tensor
point_set = torch.from_numpy(point_set)
可以使用ros_numpy將rosmsg轉(zhuǎn)換為numpy信息