python 畫(huà)3維軌跡圖并進(jìn)行比較的實(shí)例
一. 數(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)行比較的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
python實(shí)現(xiàn)代碼行數(shù)統(tǒng)計(jì)示例分享
這篇文章主要介紹了python實(shí)現(xiàn)代碼行數(shù)統(tǒng)計(jì)的示例,需要的朋友可以參考下2014-02-02
pycharm?使用conda虛擬環(huán)境的詳細(xì)配置過(guò)程
這篇文章主要介紹了pycharm?使用conda虛擬環(huán)境,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-03-03
python爬取全國(guó)火鍋店數(shù)量并可視化展示
這篇文章主要介紹了python爬取全國(guó)火鍋店數(shù)量并可視化展示,文章通過(guò)獲取全國(guó)不同城市火鍋店數(shù)量情況,并將這些數(shù)據(jù)進(jìn)行可視化展示,下文詳細(xì)內(nèi)容介紹,需要的小伙伴可以參考2022-05-05
使用tensorflow根據(jù)輸入更改tensor shape
這篇文章主要介紹了使用tensorflow根據(jù)輸入更改tensor shape,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-06-06
pytorch實(shí)現(xiàn)mnist手寫(xiě)彩色數(shù)字識(shí)別
這篇文章主要介紹了pytorch-實(shí)現(xiàn)mnist手寫(xiě)彩色數(shù)字識(shí)別,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容姐介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-09-09
Python使用Chardet庫(kù)檢測(cè)字符編碼的操作詳解
在處理文本數(shù)據(jù)時(shí),字符編碼問(wèn)題是一個(gè)常見(jiàn)的挑戰(zhàn),如果編碼不正確,可能會(huì)導(dǎo)致亂碼問(wèn)題,而 Chardet 是 Python 中非常實(shí)用的一個(gè)庫(kù),可以幫助我們快速檢測(cè)文件或字符串的編碼格式,本文給大家詳細(xì)介紹了Python Chardet 庫(kù)用法,需要的朋友可以參考下2025-01-01

