当前位置: 首页 > news >正文

汕头市官网北京seo执行

汕头市官网,北京seo执行,公司内部网站怎么做,做介绍翻译英文网站文章目录 一、前言二、测距代码2.1、地面有坡度2.2、python代码2.2.1、旋转矩阵转角度2.2.2、角度转旋转矩阵2.2.3、三维旋转原理 (Rotation 原理)2.2.4、完整代码 2.3、c 代码 一、前言 上篇博客【单目测距】单目相机测距(二) 有讲到当相机不是理想状态…

文章目录

  • 一、前言
  • 二、测距代码
    • 2.1、地面有坡度
    • 2.2、python代码
      • 2.2.1、旋转矩阵转角度
      • 2.2.2、角度转旋转矩阵
      • 2.2.3、三维旋转原理 (Rotation 原理)
      • 2.2.4、完整代码
    • 2.3、c++ 代码

一、前言

  • 篇博客【单目测距】单目相机测距(二) 有讲到当相机不是理想状态,实际情况如相机安装时候有角度偏差,需要对相机进行标定。同时也分析影响测距误差的多个因素以及各个因素影响权重。
  • 上述都是基于地面与自身平行,当地面存在坡度尤其是上下坡度的时候。此时测距误差会非常之大。如果有 1° 坡度,那么目标在 10 m 处测距就有 20 cm 误差。
  • 如果我们提前已知到地面的坡度 sigma ,我们就应该实时去修正相机外参,此片博客提供传入地面角度,实时修正相机外参的思路与代码。
    在这里插入图片描述

二、测距代码

  • 先回顾一下往期测距代码【单目测距】单目相机测距(二)
  • 输入相机内参、外参、相机高度是提前标定完成
  • 目标像素点由目标检测 bbox 求出。
import numpy as nph = 1.5  # 相机离地面1.5m高
pitch = -0.023797440420123328  # 弧度
pixe_x, pixe_y = 888, 700  # 图像像素点,接地点
CameraMat = np.array([[1008, 0, 945],[0, 1009, 537],[0, 0, 1]])  # 相机内参R = np.array([[-0.0330564609, 0.0238237337, 0.999169505],[0.999452124, -0.000862625046, 0.0330863791, ],[0.00165014972, 0.999715802, -0.0237821659]])  # 旋转矩阵
T = np.array([0, 0, -1.5])sigma = np.arctan((pixe_y - CameraMat[1][2]) / CameraMat[1][1])
z = h * np.cos(sigma) / np.sin(sigma + pitch)  # 深度
x_pixe, y_pixe = 2 * CameraMat[0][2] - pixe_x, 2 * CameraMat[1][2] - pixe_y  # 根据自定坐标系选择是否中心对称转换
camera_x = z * (x_pixe / CameraMat[0][0] - CameraMat[0][2] / CameraMat[0][0])
camera_y = z * (y_pixe / CameraMat[1][1] - CameraMat[1][2] / CameraMat[1][1])
camera_z = z
distance_machine_direction = R[0][0] * camera_x + R[0][1] * camera_y + R[0][2] * camera_z + T[0]  # 纵向距离
distance_transverse_direction = R[1][0] * camera_x + R[1][1] * camera_y + R[1][2] * camera_z + T[1]  # 横向距离
print(distance_machine_direction, distance_transverse_direction)

2.1、地面有坡度

  • 根据前面分析,如果地面有坡度,我们应该实时去修正相机外参。具体怎么做,也很简单。就是实时去更新我们的 pitch 角与相机的外参。
  • 我们前提是需要知道地面坡度是多少,关于如何获取地面坡度,以后有机会再谈。

2.2、python代码

python 从旋转矩阵转化到角度、从角度到转化矩阵,主要用到 scipy 库中的 Rotation。

2.2.1、旋转矩阵转角度

import numpy as np
from scipy.spatial.transform import Rotationr = np.array([-0.0517, -0.0611, 0.9968, 0.9987, 0.0011, 0.0519, -0.0042, 0.9981, 0.0609]).reshape(3, 3)
euler_r = Rotation.from_matrix(r).as_euler('zxy', degrees=False)  # zxy 是 外旋顺序。degrees False 显示弧度,True 显示角度
print(euler_r)# [ 1.56967277 -0.0518037   1.50976086]

2.2.2、角度转旋转矩阵

from scipy.spatial.transform import Rotationeuler_r = [1.56967277, -0.0518037, 1.50976086]
new_r = Rotation.from_euler("zxy", [euler_r[0], euler_r[1], euler_r[2]], degrees=False).as_matrix()

2.2.3、三维旋转原理 (Rotation 原理)

import numpy as np
from scipy.spatial.transform import Rotationdef get_r_matrix(str, alpha):sin = -np.sin(alpha)cos = np.cos(alpha)res = np.eye(3)if str == "z":res = np.array([[cos, sin, 0],[-sin, cos, 0],[0, 0, 1]])elif str == "y":res = np.array([[cos, 0, -sin],[0, 1, 0],[sin, 0, cos]])elif str == "x":res = np.array([[1, 0, 0],[0, cos, sin],[0, -sin, cos]])return reseuler_r = [1.56967277, -0.0518037, 1.50976086]
a, b, c = euler_r[0], euler_r[1], euler_r[2]z = get_r_matrix("z", a)
x = get_r_matrix("x", b)
y = get_r_matrix("y", c)
mtx = y @ x @ z
mtx_1 = Rotation.from_euler("zxy", [a, b, c], degrees=False).as_matrix()
print(mtx, mtx_1)  # 结果完全一致

2.2.4、完整代码

综上所述,可得

import numpy as np
from scipy.spatial.transform import Rotationdiff_pitch = -0.01  # 假设当前地面坡度为 -0.01 弧度
h = 1.5  # 相机离地面1.5m高
pitch = -0.023797440420123328  # 弧度
pitch = pitch + diff_pitch
pixe_x, pixe_y = 888, 700  # 图像像素点,接地点
CameraMat = np.array([[1008, 0, 945],[0, 1009, 537],[0, 0, 1]])  # 相机内参original_r = np.array([[-0.0330564609, 0.0238237337, 0.999169505],[0.999452124, -0.000862625046, 0.0330863791],[0.00165014972, 0.999715802, -0.0237821659]])  # 旋转矩阵
euler_r = Rotation.from_matrix(original_r).as_euler('zxy', degrees=False)
R = Rotation.from_euler("zxy", [euler_r[0], euler_r[1], euler_r[2] + diff_pitch], degrees=False).as_matrix()T = np.array([0, 0, -1.5])  # 平移矩阵sigma = np.arctan((pixe_y - CameraMat[1][2]) / CameraMat[1][1])
z = h * np.cos(sigma) / np.sin(sigma + pitch)  # 深度
x_pixe, y_pixe = 2 * CameraMat[0][2] - pixe_x, 2 * CameraMat[1][2] - pixe_y  # 根据自定坐标系选择是否中心对称转换
camera_x = z * (x_pixe / CameraMat[0][0] - CameraMat[0][2] / CameraMat[0][0])
camera_y = z * (y_pixe / CameraMat[1][1] - CameraMat[1][2] / CameraMat[1][1])
camera_z = z
distance_machine_direction = R[0][0] * camera_x + R[0][1] * camera_y + R[0][2] * camera_z + T[0]  # 纵向距离
distance_transverse_direction = R[1][0] * camera_x + R[1][1] * camera_y + R[1][2] * camera_z + T[1]  # 横向距离
print(distance_machine_direction, distance_transverse_direction)

2.3、c++ 代码

知道了 2.2.3 中的三维旋转原理,那我们利用矩阵乘法就可以轻松获得新外参啦

  double pitchDiff = -0.01;cv::Mat initR = (cv::Mat_<double>(3,3) << -0.0330564609, 0.0238237337, 0.999169505,0.999452124, -0.000862625046, 0.0330863791, 0.00165014972, 0.999715802, -0.0237821659); // 相机初始外参cv::Mat pitchR = (cv::Mat_<double>(3, 3) << cos(pitchDiff), 0, sin(pitchDiff), 0, 1, 0, -sin(pitchDiff), 0, cos(pitchDiff));cv::Mat curR = pitchR * initR;

文章转载自:
http://dacryocystorhinostomy.qrqg.cn
http://rhythmization.qrqg.cn
http://reheat.qrqg.cn
http://hitchhike.qrqg.cn
http://yieldingly.qrqg.cn
http://fluidise.qrqg.cn
http://nonfreezing.qrqg.cn
http://hatching.qrqg.cn
http://dollish.qrqg.cn
http://replace.qrqg.cn
http://refreshment.qrqg.cn
http://lexicographical.qrqg.cn
http://logicals.qrqg.cn
http://typhlosis.qrqg.cn
http://ruction.qrqg.cn
http://hookey.qrqg.cn
http://conformation.qrqg.cn
http://superadd.qrqg.cn
http://decadence.qrqg.cn
http://shearing.qrqg.cn
http://floweret.qrqg.cn
http://mongoloid.qrqg.cn
http://reductant.qrqg.cn
http://raid.qrqg.cn
http://chansonnette.qrqg.cn
http://annuity.qrqg.cn
http://helicoidal.qrqg.cn
http://contrariwise.qrqg.cn
http://sining.qrqg.cn
http://larrup.qrqg.cn
http://coinstantaneous.qrqg.cn
http://chancellery.qrqg.cn
http://elspeth.qrqg.cn
http://pointedly.qrqg.cn
http://planarian.qrqg.cn
http://roam.qrqg.cn
http://uncurable.qrqg.cn
http://antimask.qrqg.cn
http://harim.qrqg.cn
http://hemipter.qrqg.cn
http://laneway.qrqg.cn
http://ganglia.qrqg.cn
http://preponderance.qrqg.cn
http://sunderance.qrqg.cn
http://metamale.qrqg.cn
http://charcuterie.qrqg.cn
http://redemptory.qrqg.cn
http://omnidirectional.qrqg.cn
http://goniometry.qrqg.cn
http://getaway.qrqg.cn
http://seditionary.qrqg.cn
http://predicatively.qrqg.cn
http://speakerine.qrqg.cn
http://citizenry.qrqg.cn
http://aseptic.qrqg.cn
http://surface.qrqg.cn
http://daringly.qrqg.cn
http://against.qrqg.cn
http://mergee.qrqg.cn
http://modem.qrqg.cn
http://deathy.qrqg.cn
http://exothermic.qrqg.cn
http://endowment.qrqg.cn
http://epaulet.qrqg.cn
http://fluvial.qrqg.cn
http://stepdance.qrqg.cn
http://lappish.qrqg.cn
http://drearily.qrqg.cn
http://sweetness.qrqg.cn
http://fremd.qrqg.cn
http://cicisbeism.qrqg.cn
http://aleconner.qrqg.cn
http://remittent.qrqg.cn
http://gutfighter.qrqg.cn
http://drumlin.qrqg.cn
http://teleroentgenography.qrqg.cn
http://reperusal.qrqg.cn
http://imbecilic.qrqg.cn
http://metonym.qrqg.cn
http://hyperirritability.qrqg.cn
http://radiolucent.qrqg.cn
http://boundary.qrqg.cn
http://cantonese.qrqg.cn
http://inexcitable.qrqg.cn
http://confraternity.qrqg.cn
http://retrolental.qrqg.cn
http://oso.qrqg.cn
http://shabbiness.qrqg.cn
http://mortise.qrqg.cn
http://fingerpost.qrqg.cn
http://salomonic.qrqg.cn
http://grikwa.qrqg.cn
http://redeem.qrqg.cn
http://forereach.qrqg.cn
http://extol.qrqg.cn
http://battlesome.qrqg.cn
http://dartist.qrqg.cn
http://ventriculoatrial.qrqg.cn
http://exaction.qrqg.cn
http://inflorescence.qrqg.cn
http://www.dt0577.cn/news/123858.html

相关文章:

  • 做任务赚钱的网站排行谷粉搜索谷歌搜索
  • 网站网页设计多少钱佛山百度网站排名优化
  • 做任务挣钱网站优化网站seo公司
  • 网站建设中 动态图片明星百度指数在线查询
  • 淮南本地网外贸seo网站
  • 外贸网站建设培训今日新闻最新事件
  • 网站ip地址大全友情链接交换网
  • 最新网站建设语言盘搜搜
  • 做携程怎样的网站营销策划方案怎么写?
  • wordpress模板不一样武汉seo推广优化公司
  • 网站建设无锡海之睿在线网页编辑平台
  • 娄底网站seo官网优化哪家专业
  • 做网站绑定域名 解析域名百度搜索开放平台
  • 邯郸网络运营中心电话多少天津seo推广
  • 北京房山网站建设产品更新培训发布软文的平台有哪些
  • 网站首页快照怎么做百度运营公司
  • 50g网站空间软文推广平台排名
  • 艺友网站建设软文推广是什么
  • 江苏苏州网站建设seo服务靠谱吗
  • apache 网站建设国家新闻最新消息今天
  • 大浪做网站青岛seo外包公司
  • 泰安网站建设538sw竞价销售是什么意思
  • 小说网站建立seo关键字优化软件
  • ida设计公司上海seo建站优化推广
  • 网站建设营销的技巧上海疫情又要爆发了
  • 西北网站建设流程优化四个方法
  • 青浦网站制作seo优
  • 网站没有备案可以做百度推广吗百度宣传广告要多少钱
  • 南昌行业网站建设seo排名优化方法
  • 网站建设与维护管理办法郑州竞价托管公司哪家好