婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > python 三邊測量定位的實現(xiàn)代碼

python 三邊測量定位的實現(xiàn)代碼

熱門標簽:地圖標注微信發(fā)送位置不顯示 蓋州市地圖標注 南京銷售外呼系統(tǒng)軟件 上海機器人外呼系統(tǒng)哪家好 浙江電銷卡外呼系統(tǒng)好用嗎 地圖制圖標注位置改變是移位嗎 房產(chǎn)電銷外呼系統(tǒng) 315電話機器人廣告 地圖標注的意義點

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

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 16 10:50:29 2018
@author: dag
"""
import sympy
import numpy as np
import math
from matplotlib.pyplot import plot
from matplotlib.pyplot import show
import matplotlib.pyplot as plt
import matplotlib
#解決無法顯示中文問題,fname是加載字體路徑,根據(jù)自身pc實際確定,具體請百度
zhfont1 = matplotlib.font_manager.FontProperties(fname='/System/Library/Fonts/Hiragino Sans GB W3.ttc')
 
#隨機產(chǎn)生3個參考節(jié)點坐標
maxy = 1000
maxx = 1000
cx = maxx*np.random.rand(3)
cy = maxy*np.random.rand(3)
dot1 = plot(cx,cy,'k^')
 
#生成盲節(jié)點,以及其與參考節(jié)點歐式距離
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]
    
#解算得到定位節(jié)點坐標
[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(['參考節(jié)點','盲節(jié)點','定位節(jié)點'], loc='lower right',prop=zhfont1)
show() 
derror = math.sqrt(np.square(locx-mtx) + np.square(locy-mty)) 
print(derror) 

輸出效果圖:

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

看代碼吧~

import cv2
import numpy as np
import scipy.io as scio
if __name__ == '__main__':
    print("main function.")
    #驗證點
    point = np.array([1.0 ,2.0, 3.0])
    #獲取相機參數(shù)
    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,:])

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。如有錯誤或未考慮完全的地方,望不吝賜教。

您可能感興趣的文章:
  • Python實現(xiàn)圖片指定位置加圖片水印(附Pyinstaller打包exe)
  • python3定位并識別圖片驗證碼實現(xiàn)自動登錄功能
  • python selenium xpath定位操作
  • 基于selenium及python實現(xiàn)下拉選項定位select
  • Python selenium模塊實現(xiàn)定位過程解析
  • python文件操作seek()偏移量,讀取指正到指定位置操作
  • 利用Python實現(xiàn)某OA系統(tǒng)的自動定位功能
  • python3 使用traceback定位異常實例

標簽:陽泉 赤峰 臨汾 金華 雙鴨山 日照 克拉瑪依 貴州

巨人網(wǎng)絡通訊聲明:本文標題《python 三邊測量定位的實現(xiàn)代碼》,本文關鍵詞  python,三邊,測量,定位,的,;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《python 三邊測量定位的實現(xiàn)代碼》相關的同類信息!
  • 本頁收集關于python 三邊測量定位的實現(xiàn)代碼的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 山阳县| 丁青县| 宣化县| 阿拉善右旗| 余庆县| 克拉玛依市| 屏东市| 高平市| 阿合奇县| 金堂县| 武穴市| 吉林市| 兴化市| 岳西县| 建平县| 南涧| 汉阴县| 梓潼县| 南城县| 海盐县| 新平| 隆安县| 潞城市| 饶平县| 南丰县| 巴里| 河南省| 聂拉木县| 安阳县| 会昌县| 文安县| 诸城市| 英超| 昌黎县| 宣化县| 扎囊县| 华阴市| 杭州市| 无极县| 胶南市| 平利县|