av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術文章
文章詳情頁

python 三邊測量定位的實現代碼

瀏覽:3日期:2022-06-21 15:55:12

定位原理很簡單,故不贅述,直接上源碼,內附注釋。(如果對您的學習有所幫助,還請幫忙點個贊,謝謝了)

#!/usr/bin/env python3# -*- coding: utf-8 -*-'''Created on Wed May 16 10:50:29 2018@author: dag'''import sympyimport numpy as npimport mathfrom matplotlib.pyplot import plotfrom matplotlib.pyplot import showimport matplotlib.pyplot as pltimport matplotlib#解決無法顯示中文問題,fname是加載字體路徑,根據自身pc實際確定,具體請百度zhfont1 = matplotlib.font_manager.FontProperties(fname=’/System/Library/Fonts/Hiragino Sans GB W3.ttc’) #隨機產生3個參考節點坐標maxy = 1000maxx = 1000cx = maxx*np.random.rand(3)cy = maxy*np.random.rand(3)dot1 = plot(cx,cy,’k^’) #生成盲節點,以及其與參考節點歐式距離mtx = maxx*np.random.rand()mty = maxy*np.random.rand()plt.hold(’on’)dot2 = plot(mtx,mty,’go’)da = math.sqrt(np.square(mtx-cx[0])+np.square(mty-cy[0]))db = math.sqrt(np.square(mtx-cx[1])+np.square(mty-cy[1])) dc = math.sqrt(np.square(mtx-cx[2])+np.square(mty-cy[2])) #計算定位坐標 def triposition(xa,ya,da,xb,yb,db,xc,yc,dc): x,y = sympy.symbols(’x y’) f1 = 2*x*(xa-xc)+np.square(xc)-np.square(xa)+2*y*(ya-yc)+np.square(yc)-np.square(ya)-(np.square(dc)-np.square(da)) f2 = 2*x*(xb-xc)+np.square(xc)-np.square(xb)+2*y*(yb-yc)+np.square(yc)-np.square(yb)-(np.square(dc)-np.square(db)) result = sympy.solve([f1,f2],[x,y]) locx,locy = result[x],result[y] return [locx,locy] #解算得到定位節點坐標[locx,locy] = triposition(cx[0],cy[0],da,cx[1],cy[1],db,cx[2],cy[2],dc)plt.hold(’on’)dot3 = plot(locx,locy,’r*’) #顯示腳注x = [[locx,cx[0]],[locx,cx[1]],[locx,cx[2]]]y = [[locy,cy[0]],[locy,cy[1]],[locy,cy[2]]]for i in range(len(x)): plt.plot(x[i],y[i],linestyle = ’--’,color =’g’ )plt.title(’三邊測量法的定位’,fontproperties=zhfont1) plt.legend([’參考節點’,’盲節點’,’定位節點’], loc=’lower right’,prop=zhfont1)show() derror = math.sqrt(np.square(locx-mtx) + np.square(locy-mty)) print(derror)

輸出效果圖:

python 三邊測量定位的實現代碼

補充:python opencv實現三角測量(triangulation)

看代碼吧~

import cv2import numpy as npimport scipy.io as scioif __name__ == ’__main__’: print('main function.') #驗證點 point = np.array([1.0 ,2.0, 3.0]) #獲取相機參數 cams_data = scio.loadmat(’/data1/dy/SuperSMPL/data/AMAfMvS_Dataset/cameras_I_crane.mat’) Pmats = cams_data[’Pmats’] # Pmats(8, 3, 4) 投影矩陣 P1 = Pmats[0,::] P3 = Pmats[2,::] #通過投影矩陣將點從世界坐標投到像素坐標 pj1 = np.dot(P1, np.vstack([point.reshape(3,1),np.array([1])])) pj3 = np.dot(P3, np.vstack([point.reshape(3,1),np.array([1])])) point1 = pj1[:2,:]/pj1[2,:]#兩行一列,齊次坐標轉化 point3 = pj3[:2,:]/pj3[2,:] #利用投影矩陣以及對應像素點,進行三角測量 points = cv2.triangulatePoints(P1,P3,point1,point3) #齊次坐標轉化并輸出 print(points[0:3,:]/points[3,:])

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。如有錯誤或未考慮完全的地方,望不吝賜教。

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 久久99深爱久久99精品 | 亚洲一区二区久久 | 狠狠操狠狠干 | 欧美精品一区二区三区在线播放 | 国产精品久久久久久久久久久新郎 | 四色永久 | a视频在线播放 | 日本一区二区高清不卡 | 国产精品久久久久久久久久妇女 | 91高清在线观看 | 天堂成人国产精品一区 | 久久国产视频网 | 成人国产精品免费观看 | 国产精品成人一区 | 久久久久久国产一区二区三区 | 国产一级电影在线观看 | 亚洲一区中文字幕 | 久久久久久久久久久久久9999 | 精品视频一区二区三区 | 久久久久中文字幕 | 黄网站免费在线 | 国产精品91久久久久久 | 国产不卡一区在线观看 | 99re99| 国产99视频精品免视看9 | 精品在线一区二区三区 | www精品美女久久久tv | 中文字幕视频网 | 成人亚洲性情网站www在线观看 | 国产专区在线 | 日本福利视频 | 国产精品成人国产乱一区 | 中文字幕av在线播放 | 亚洲人成人一区二区在线观看 | 国产小视频在线观看 | 亚洲国产精品一区二区三区 | 三区在线| 成人在线观看免费爱爱 | 成人中文字幕在线观看 | 国产午夜精品一区二区 | 日日夜夜天天综合 |