def save_pl(path, pl): if not os.path.exists(os.path.split(path)[0]): os.makedirs(os.path.split(path)[0]) myfile = file(path, "w") point_num = pl.shape[0] for j in range(point_num): if len(pl[j])==3: print >> myfile, "%f %f %f" % (pl[j,0],pl[j,1],pl[j,2]) elif len(pl[j])==6: print >> myfile, "%f %f %f %f %f %f" % (pl[j, 0], pl[j, 1], pl[j, 2],pl[j, 3],pl[j, 4],pl[j, 5]) # print >> myfile, "%f %f %f %f %f %f %f" % ( # pl[j, 0], pl[j, 1], pl[j, 2], pl[j, 3], pl[j, 4], pl[j, 5], pl[j, 2]) elif len(pl[j])==7: print >> myfile, "%f %f %f %f %f %f %f" % (pl[j, 0], pl[j, 1], pl[j, 2],pl[j, 3],pl[j, 4],pl[j, 5],pl[j, 2]) myfile.close() if np.random.rand()>1.9: show3d.showpoints(pl[:, 0:3])
print("Shutdown .....") while not self.queue.empty(): self.queue.get() print("Remove all queue data") if __name__ == '__main__': folder = '/home/lqyu/workspace/PointSR/perfect_models' fetchworker = Fetcher(folder) fetchworker.start() for cnt in range(200): start = time.time() input, gt, radius = fetchworker.fetch() assert len(input) == len(gt) assert len(input) == 32 end = time.time() print(cnt, end - start) for i in range(len(input)): cv2.imshow('data', input[i, :, 0:3]) while True: cmd = show3d.showpoints(input[i, :, 0:3]) if cmd == ord(' '): break elif cmd == ord('q'): break if cmd == ord('q'): break fetchworker.shutdown()
def save_xyz(path, data): if not os.path.exists(os.path.split(path)[0]): os.makedirs(os.path.split(path)[0]) np.savetxt(path, data, fmt='%.6f') if np.random.rand() > 1.9: show3d.showpoints(data[:, 0:3])