20240219画图程序

1. PTZ在惯性态时,不同视场角下的【发送】角速度和【理论响应】角速度

1.1 优化前

请添加图片描述

import numpy as np
import matplotlib.pyplot as plt# PTZ在惯性态时,不同视场角下的【发送】角速度和【理论响应】角速度
ATROffset_x = np.linspace(0, 60, 120)
y2 = ATROffset_x * 2 / 28
y4 = ATROffset_x * 4 / 28
y6 = ATROffset_x * 6 / 28
y8 = ATROffset_x * 8 / 28
y10 = ATROffset_x * 10 / 28
y12 = ATROffset_x * 12 / 28
y14 = ATROffset_x * 14 / 28
y16 = ATROffset_x * 16 / 28
y18 = ATROffset_x * 18 / 28
y20 = ATROffset_x * 20 / 28
y22 = ATROffset_x * 22 / 28
y24 = ATROffset_x * 24 / 28
y26 = ATROffset_x * 26 / 28
y28 = ATROffset_x * 28 / 28plt.plot(ATROffset_x, y2, label='field angle: 2 degrees')
plt.plot(ATROffset_x, y4, linestyle='dotted',label='field angle: 4 degrees')
plt.plot(ATROffset_x, y6, linestyle='--',label='field angle: 6 degrees')
plt.plot(ATROffset_x, y8, linestyle='-.', label='field angle: 8 degrees')plt.plot(ATROffset_x, y10, label='field angle: 10 degrees')
plt.plot(ATROffset_x, y12, linestyle='dotted', label='field angle: 12 degrees')
plt.plot(ATROffset_x, y14, linestyle='--',label='field angle: 14 degrees')
plt.plot(ATROffset_x, y16, linestyle='-.', label='field angle: 16 degrees')plt.plot(ATROffset_x, y18, label='field angle: 18 degrees')
plt.plot(ATROffset_x, y20, linestyle='dotted', label='field angle: 20 degrees')
plt.plot(ATROffset_x, y22, linestyle='--',label='field angle: 22 degrees')
plt.plot(ATROffset_x, y24, linestyle='-.', label='field angle: 24 degrees')plt.plot(ATROffset_x, y26, linestyle='dotted', label='field angle: 26 degrees')
plt.plot(ATROffset_x, y28, label='field angle: 28 degrees')plt.xlabel('sending value[degree/second]')
plt.ylabel('thertical response[degree/second]')
plt.title('PTZ angular velocity: sending value & thertical response')
handles, labels = plt.gca().get_legend_handles_labels()
# plt.legend(handles[::-1], labels[::-1],loc='right')
plt.legend(handles[::-1], labels[::-1])
plt.grid()
plt.show()

1.2 优化后

请添加图片描述

import numpy as np
import matplotlib.pyplot as pltATROffset_x = np.linspace(0, 60, 120)
linestyles = ['-', 'dotted', '--', '-.', '-', 'dotted', '--', '-.', '-', 'dotted', '--', '-.', '-', 'dotted']
labels = [f'field angle: {i} degrees' for i in range(2, 30, 2)]for i, linestyle in enumerate(linestyles):y = ATROffset_x * (i + 2) / 28plt.plot(ATROffset_x, y, linestyle=linestyle, label=labels[i])plt.xlabel('sending value[degree/second]')
plt.ylabel('thertical response[degree/second]')
plt.title('PTZ angular velocity: sending value & thertical response')
handles, labels = plt.gca().get_legend_handles_labels()
plt.legend(handles[::-1], labels[::-1])
plt.grid()
plt.show()

2. 像素偏移与发送角速度

请添加图片描述

import numpy as np
import matplotlib.pyplot as plt# 分段函数
def piecewise_function(x):if x >80: return x/9elif x>30: return x/4elif x>10: return x/1.8elif x>3: return x/1.8elif x>1: return xelse: return 0# 生成x值
x = np.linspace(0, 512, 2000)
# 计算y值
y1 = [piecewise_function(xi) for xi in x]
y2 = 2.5*(x**(0.5))
# y3 = 2.5*(x**(0.8))points = [(506.25, piecewise_function(506.25))]
for point in points:plt.plot(point[0], point[1], 'ro')plt.annotate(f'({point[0]}, {point[1]:.2f})', (point[0], point[1]), textcoords="offset points", xytext=(0,10), ha='center')# 绘制图形
plt.plot(x, y1, label='piecewise function', linestyle='-.')
plt.plot(x, y2, label='2.5*pow(x,0.5)')
# plt.plot(x, y3, label='x**0.8')plt.xlabel('pixel offset[pixel]')
plt.ylabel('sending value[degree/second]')
plt.title('PTZ angular velocity: sending value & pixel offset')
plt.grid()
plt.legend()
plt.show()

3. 估算不同焦距下的目标大小

3.1 原理

  • 【任务】:已知POD与目标之间的高度差3000m和水平距离2000m,需要解算7m*3m目标在POD观察画面中的大小
  • 【途径】:利用视场角解算视野大小,绘制目标在POD观察画面中的大小
    • 解算视场角大小:
      • fieldAngle_yaw = arctan(5.632/focalDistance)*180/Pi
      • fieldAngle_pitch = arctan(4.224/focalDistance)*180/Pi
    • 解算POD与目标的直线距离distance
    • 解算视野覆盖的实际长和宽
      • fieldWidth = 2*tan(fieldAngle_yaw/2)/disctance
      • fieldWidth = 2*tan(fieldAngle_pitch/2)/disctance
    • 解算目标在视野中的比例后,可得3.2中的图像

请添加图片描述

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D# 参数方程定义的单位球面
def sphere(u, v):theta = u * 2 * np.piphi = v * np.pix = np.sin(phi) * np.cos(theta)y = np.sin(phi) * np.sin(theta)z = np.cos(phi)return x, y, zdef plot_rectangle_tangent_to_point(point):# 计算点到原点的单位向量point_normalized = point / np.linalg.norm(point)# 找到一个与点到原点的向量垂直的向量perpendicular_vector_1 = np.cross(point_normalized, [1, 0, 0])if np.allclose(perpendicular_vector_1, [0, 0, 0]):# 如果点到原点的向量与[1, 0, 0]平行,则选择[0, 1, 0]作为第二个向量perpendicular_vector_1 = np.cross(point_normalized, [0, 1, 0])perpendicular_vector_1 /= np.linalg.norm(perpendicular_vector_1)# 找到与第一个向量垂直的第二个向量perpendicular_vector_2 = np.cross(point_normalized, perpendicular_vector_1)perpendicular_vector_2 /= np.linalg.norm(perpendicular_vector_2)# 生成矩形的四个顶点rectangle_half_side = 0.5  # 矩形边长的一半rectangle_vertices = np.array([point_normalized + rectangle_half_side * perpendicular_vector_1 + rectangle_half_side * perpendicular_vector_2,point_normalized - rectangle_half_side * perpendicular_vector_1 + rectangle_half_side * perpendicular_vector_2,point_normalized - rectangle_half_side * perpendicular_vector_1 - rectangle_half_side * perpendicular_vector_2,point_normalized + rectangle_half_side * perpendicular_vector_1 - rectangle_half_side * perpendicular_vector_2,point_normalized + rectangle_half_side * perpendicular_vector_1 + rectangle_half_side * perpendicular_vector_2  # 重复第一个点以闭合图形])# 绘制矩形切面fig = plt.figure(figsize=(10, 10))ax = fig.add_subplot(111, projection='3d')ax.plot(rectangle_vertices[:, 0], rectangle_vertices[:, 1], rectangle_vertices[:, 2], color='r')ax.scatter(point[0], point[1], point[2], color='b', s=50)  # 绘制点# 定义两个点point1 = pointpoint2 = np.array([0, 0, 0])# 绘制两个点ax.scatter(point1[0], point1[1], point1[2], color='r', s=100)ax.scatter(point2[0], point2[1], point2[2], color='b', s=100)# 绘制连线ax.plot([point1[0], point2[0]], [point1[1], point2[1]], [point1[2], point2[2]], color='k', linestyle='--')# 绘制中点fyo = (point_normalized + rectangle_half_side * perpendicular_vector_1 + rectangle_half_side * perpendicular_vector_2 + point_normalized + rectangle_half_side * perpendicular_vector_1 - rectangle_half_side * perpendicular_vector_2)/2ax.scatter(fyo[0], fyo[1], fyo[2], color='b', s=50)  # 绘制点# 绘制连线ax.plot([fyo[0], point2[0]], [fyo[1], point2[1]], [fyo[2], point2[2]], color='k', linestyle='--')# 绘制连线-平面内ax.plot([fyo[0], point[0]], [fyo[1], point[1]], [fyo[2], point[2]], color='k', linestyle='--')# 创建参数u = np.linspace(0, 2, 100)v = np.linspace(0, 2, 100)u, v = np.meshgrid(u, v)# 计算球面上的点x, y, z = sphere(u, v)# 绘制单位球面ax.plot_surface(x, y, z, color='b', alpha=0.02)# 画出xyz轴ax.plot([0, 1], [0, 0], [0, 0], color='red', linestyle='-', linewidth=2)ax.plot([0, 0], [0, 1], [0, 0], color='green', linestyle='-', linewidth=2)ax.plot([0, 0], [0, 0], [0, 1], color='blue', linestyle='-', linewidth=2)# 设置坐标轴等比例ax.set_box_aspect([1,1,1])# 设置坐标轴标签ax.set_xlabel('X')ax.set_ylabel('Y')ax.set_zlabel('Z')# 设置x轴的刻度ax.set_xticks([-1, -0.5, 0, 0.5, 1])# 设置y轴的刻度ax.set_yticks([-1, -0.5, 0, 0.5, 1])# 设置z轴的刻度ax.set_zticks([-1, -0.5, 0, 0.5, 1])# 设置标题plt.title("Since: tan(fieldAngle/2) = (fieldWidth/2) / distance\n\nThen: fieldWidth = 2 * tan(fieldAngle/2) * distance")plt.show()point_on_sphere = np.array([-0.55, 0, -0.83])
plot_rectangle_tangent_to_point(point_on_sphere)

3.2 绘图

  • POD与目标之间高度差3000m、水平距离2000m,目标尺寸7m*3m
  • 不同焦距下,该目标在POD观察画面中的大小如图所示请添加图片描述
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
import mathrelative_target_height = 3000
relative_target_horizontal = 2000
relative_distance = math.sqrt(relative_target_height*relative_target_height + relative_target_horizontal*relative_target_horizontal)
print("relative_distance: ", relative_distance)fig, ax = plt.subplots()# 创建一个新的图形
plt.title("ROI SIZE of 7m*3m target: 3000m high & 2000m distance")# 设置标题def fd2pic(fd):horizontal_draw = np.tan(math.atan(5.632/fd)/2) * relative_distance * 2vertical_draw = np.tan(math.atan(4.224/fd)/2) * relative_distance * 2# 添加第一个框rect = patches.Rectangle((6*7/horizontal_draw*1024, 14*3/vertical_draw*768), 7/horizontal_draw*1024, 3/vertical_draw*768, linewidth=1, edgecolor='r', facecolor='none')ax.add_patch(rect)# 在第一个框旁边打印文字ax.text(7*7/horizontal_draw*1024+20, 14*3/vertical_draw*768, "fd: {:.2f}".format(fd), fontsize=12, color='r')for i in range(9):fd2pic(max(40*i,10.59))plt.xlim(0, 1024)
plt.ylim(0, 768)
plt.xticks([0, 1024])
plt.yticks([0, 768])
plt.show()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/477837.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C++题目打卡2.18

从今天开始我们又将讲4天题目。 题目列表 1.分配T4 2.组合T5 #分配T4 这里很明显是&#xff08;200 110&#xff09; - 330的差值最小。 我们先想到了一个想法就是输入时哪个堆大,加那个。 #include <bits/stdc.h> using namespace std; int main(){int n, ans1 0, …

Nodejs 第三十八章(mysql2)

在之前的篇章中&#xff0c;已经补充完成mysql的基本知识&#xff0c;那么现在开始&#xff0c;我们需要把mysql和express,nodejs连接起来。 安装依赖 npm install mysql2 express js-yamlmysql2 用来连接mysql和编写sq语句express 用来提供接口 增删改差js-yaml 用来编写配置…

达梦数据库——日常使用问题记录_未完待续

记录达梦数据库在日常使用中遇到的一些小问题&#xff0c;持续更新... 案例一&#xff1a;表空间扩容报错‘表空间上有事务未提交’ 原因&#xff1a;有会话查询表空间系统视图&#xff0c;或的确有表空间操作&#xff1b; 解决方法&#xff1a;结束相关会话 select SP_CLOSE…

300分钟吃透分布式缓存-04讲:缓存失效、穿透和雪崩问题怎么处理?

前面讲解了缓存的原理、引入&#xff0c;以及设计架构&#xff0c;总结了缓存在使用及设计架构过程中的很多套路和关键考量点。实际上&#xff0c;在缓存系统的设计架构中&#xff0c;还有很多坑&#xff0c;很多的明枪暗箭&#xff0c;如果设计不当会导致很多严重的后果。设计…

基于Java (spring-boot)的校园二手交易平台

一、项目介绍 基于Java (spring-boot)的校园二手交易平台&#xff1a;前端主要包含登录注册、求购商品、发布商品、举报、评论五个核心管理模块。后端则主要包含系统设置、物品管理、学生管理、评论管理、举报管理、新闻公告六个核心管理模块。通过此模式不同属性的用户可在系统…

白话微机:6.解释RTOS以及一些考研面试问题

一. 前言&#xff08;总结世界观&#xff09; 很久很久以前&#xff0c;有这样一个世界&#xff0c;这个世界有着现实世界一样的元素&#xff1a;那里的人又有一个别的名字叫做“数据”&#xff0c;人有0有1&#xff1b;人们也有住房&#xff0c;这些住房在这个世界叫做“存储器…

纯净住宅代理有何优势?为什么要用它?

随着互联网的快速发展&#xff0c;代理服务器已经成为许多在线活动的关键组成部分&#xff0c;从数据挖掘到网络安全。然而&#xff0c;随着技术的不断发展&#xff0c;住宅IP代理正崭露头角&#xff0c;因其在保障隐私、提升性能和应对封锁方面的卓越优势而备受瞩目。本文将深…

Java中的Arrays和Lambda表达式

Arrays和Lambda Arrays常用方法数组中是对象&#xff08;如何排序&#xff09; Lambda什么是LambdaLambda表达式的省略规则 Arrays 是一个用来操作数组的工具类 常用方法 数组中是对象&#xff08;如何排序&#xff09; 方式一 方式二 Lambda 什么是Lambda 是JDK 8 开始新…

【Linux】进程的初步认识(二)

进程的初步认识 前言查看进程通过系统调用创建进程关于创建进程的几点补充 前言 之前的一篇文章(文章链接)已经初步对于进程有了一个认识&#xff0c;这篇文章主要是介绍如何去查看进程的相关信息以及创建一个进程的相关知识 查看进程 查看进程的信息可以在/proc系统文件夹中查…

【性能测试入门必看】性能测试理论知识

一、性能测试理论知识 1、常用的七种性能测试方法 (1) 后端性能测试&#xff1a;其实&#xff0c;你平时听到的性能测试&#xff0c;大多数情况下指的是后端性能测试&#xff0c;也就是服务器端性能测试。后端性能测试&#xff0c;是通过性能测试工具模拟大量的并发用户请求&…

Unity数据持久化之PlayerPrefs

PlayerPrefs概述 什么是数据持久化 数据持久化就是将内存中的数据模型转换为存储模型&#xff0c;以及将存储模型转换为内存中的数据模型的统称。即将游戏数据存储到硬盘&#xff0c;硬盘中数据读取到游戏中&#xff0c;也就是传统意义上的存盘。 基本方法 PlayerPrefs是什么…

P4447 [AHOI2018初中组] 分组题解

题目 小可可的学校信息组总共有n个队员&#xff0c;每个人都有一个实力值。现在&#xff0c;一年一度的编程大赛就要到了&#xff0c;小可可的学校获得了若干个参赛名额&#xff0c;教练决定把学校信息组的n个队员分成若干个小组去参加这场比赛。 但是每个队员都不会愿意与实…