崔中浩 2022-01-26 23:24 采纳率: 0%
浏览 617
已结题

大疆无人机世界坐标系转像素坐标系

我想把实地的地物点标注到大疆无人机拍摄的照片上,用的是cgcs2000坐标系,我将坐标输入,返回的像素坐标和实际的地物点不能匹配上
import numpy as np
import math
from pyexiv2 import Image
import cv2
#获取了像片拍摄时云台的姿态角
def readJpgXmp(path):
 
    file_name = path
    test = Image(file_name)
    f = test.read_xmp()
    lat = f["Xmp.drone-dji.GpsLatitude"] #纬度
    lon = f["Xmp.drone-dji.GpsLongitude"] # 经度
    height = f["Xmp.drone-dji.AbsoluteAltitude"] #
    roll = f["Xmp.drone-dji.GimbalRollDegree"] #roll
    yaw = f["Xmp.drone-dji.GimbalYawDegree"] # yaw
    pitch = f["Xmp.drone-dji.GimbalPitchDegree"] # pitch
    return float(roll),float(yaw),float(pitch)
#姿态角导入到下面的函数中创建旋转矩阵
def eulerAnglesToRotationMatrix(theta):
    # 分别构建三个轴对应的旋转矩阵
    R_x = np.array([[1, 0, 0],
                    [0, math.cos(theta[0]), -math.sin(theta[0])],
                    [0, math.sin(theta[0]), math.cos(theta[0])]
                    ])

    R_y = np.array([[math.cos(theta[1]), 0, math.sin(theta[1])],
                    [0, 1, 0],
                    [-math.sin(theta[1]), 0, math.cos(theta[1])]
                    ])

    R_z = np.array([[math.cos(theta[2]), -math.sin(theta[2]), 0],
                    [math.sin(theta[2]), math.cos(theta[2]), 0],
                    [0, 0, 1]
                    ])
    # 将三个矩阵相乘,得到最终的旋转矩阵
    R = np.dot(R_z, R_y, R_x)
    return R
#计算相机的内参
def neican(pix,size,f):
    #8194*5460 #像片的尺寸(像素)
    #35.9*24 # cmos的尺寸(毫米)
    #35 #焦距(毫米)
    u0 = pix[0]/2
    v0 = pix[1]/2
    dx = size[0]/pix[0]
    dy = size[1]/pix[1]
    fx = f/dx
    fy = f/dy
    return np.array([[fx, 0, u0], [0, fy, v0], [0, 0, 1]])
#读取像片的姿态角 roll,yaw,pitch
xmpInfo = readJpgXmp(r'C:\Users\Administrator\Desktop\DJI_20210521160101_0211.JPG')
roll,yaw,pitch = xmpInfo
#旋转矩阵
r = eulerAnglesToRotationMatrix([math.radians(roll),math.radians(pitch),math.radians(yaw)]) #旋转矩阵
print(r)
#平移矩阵
t = np.array([[511914.760791,3372600.750728,231]]).T
#内参矩阵
ins = neican([8194,5460],[35.9,24],35)#内参
#世界坐标系中的地物点
list1 = np.float32([[511914.760791,3372600.750728,0]]) #3d点
#将地物点,旋转矩阵,平移矩阵,内参,传入 cv2.projectPoints()函数里
result2, _ = cv2.projectPoints(list1,r,t,ins,0)

print(result2)

返回的像素坐标不是我想要对应的地物点,请问是什么原因呢?

  • 写回答

10条回答 默认 最新

  • 崔中浩 2022-01-26 23:29
    关注

    链接:https://pan.baidu.com/s/1W7naTFQNIkyH1R8RZCd00A
    提取码:f3dx
    这是无人机拍摄的像片

    评论

报告相同问题?

问题事件

  • 系统已结题 2月3日
  • 修改了问题 1月27日
  • 修改了问题 1月26日
  • 创建了问题 1月26日

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录