溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

python中如何畫(huà)3維軌跡圖并進(jìn)行比較

發(fā)布時(shí)間:2021-07-23 14:43:04 來(lái)源:億速云 閱讀:277 作者:小新 欄目:開(kāi)發(fā)技術(shù)

小編給大家分享一下python中如何畫(huà)3維軌跡圖并進(jìn)行比較,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

一. 數(shù)據(jù)的格式

首先我們需要x,y,z三個(gè)數(shù)據(jù)進(jìn)行畫(huà)圖。從本實(shí)驗(yàn)用到的數(shù)據(jù)集KITTI 00.txt中舉例:

1.000000e+00 9.043680e-12 2.326809e-11 5.551115e-17 9.043683e-12 1.000000e+00 2.392370e-10 3.330669e-16 2.326810e-11 2.392370e-10 9.999999e-01 -4.440892e-16

一組有12個(gè)數(shù)據(jù),相當(dāng)于T={R,t},R是3×3的矩陣,t是3×1的矩陣。我們需要的是t的數(shù)據(jù)。

有些groundtruth是8個(gè)數(shù)據(jù),第一個(gè)是時(shí)間戳,在三個(gè)是x,y,z,后面四個(gè)是是四元數(shù)的數(shù)據(jù)。

代碼如下:

# import necessary module
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np

# load data from file
# you can replace this using with open
data1 = np.loadtxt("./dataset/poses/00.txt")

first_2000 = data1[:, 3]
second_2000 = data1[:, 7]
third_2000 = data1[:, 11]
data2 = np.loadtxt("../temp/kittiseq00_imu.txt")
first_1000 = data2[:, 1]
second_1000 = data2[:, 2]
third_1000 = data2[:, 3]
# print to check data
#print first_2000
#print second_2000
#print third_2000

# new a figure and set it into 3d
fig = plt.figure()
ax = fig.gca(projection='3d')

# set figure information
ax.set_title("3D_Curve")
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")

# draw the figure, the color is r = read
figure1 = ax.plot(first_2000, second_2000, third_2000, c='r')
figure2 = ax.plot(first_1000, second_1000, third_1000, c='b')
plt.show()

效果圖(電腦比較垃圾,后面的軌跡跟蹤的時(shí)候提取的特征點(diǎn)太少):

python中如何畫(huà)3維軌跡圖并進(jìn)行比較

以上是“python中如何畫(huà)3維軌跡圖并進(jìn)行比較”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI