opencv实现对象跟踪_如何使用opencv跟踪对象的距离和角度

opencv实现对象跟踪

介绍 (Introduction)

Tracking the distance and angle of an object has many practical uses, especially in robotics. This tutorial explains how to get an accurate distance and angle measurement, even when the target is at a strong angle from the camera.

跟踪物体的距离和角度有许多实际用途,尤其是在机器人技术中。 本教程说明了即使目标物与相机成强角时也如何获得准确的距离和角度测量。

开始之前 (Before we start)

Download the demo here!

在此处下载演示!

如何准确跟踪任意角度的距离 (How to accurately track distance at any angle)

Building off this article, we know that we can approximate the distance as long as we have the width of the target in pixels and cm/inches at a known distance.

建立关此文章中,我们知道,我们可以近似的距离,只要我们有目标的像素和英寸/厘米宽度的已知距离。

focal length = (known pixel Width * knownDistance) / known width

焦距 =(已知像素宽度*已知距离)/已知宽度

Distance (cm/inches/etc.) =( known Width * focal length) / pixel Width

距离(厘米/英寸/等) =(已知宽度*焦距)/像素宽度

When using width to approximate distance, the width gets smaller at an angle, decreasing the accuracy.

当使用宽度近似距离时,宽度会成一定角度变小,从而降低精度。

Instead, fitted height should be used to calculate distance, because the fitted height will always stay the same, no matter what angle.

相反,应该使用拟合高度来计算距离,因为无论高度如何,拟合高度都将始终保持不变。

Therefore, to calculate distance using fitted height, use these equations:

因此,要使用适合的高度计算距离,请使用以下公式:

focal length = (known pixel Height * knownDistance) / known height

焦距 =(已知像素高度*已知距离)/已知高度

Distance (cm/inches/etc.) = (known height * focal length) / pixel height

距离(厘米/英寸/等) =(已知高度*焦距)/像素高度

This approximation works as long as the height of the target stays the same. Also remember to use fitted height instead of bounding height because fitted height tilts with the object and bounding height does not.

只要目标的高度保持不变,这种近似就起作用。 还要记住使用拟合高度而不是边界高度,因为拟合高度会随对象倾斜而边界高度不会倾斜。

如何近似目标相对于相机的角度 (How to approximate angle of a target relative to the camera)

Angle can be approximated as long as the ratio between the target’s width and height is known.

只要知道目标的宽度和高度之比,就可以近似角度。

When there is no change in the width, the angle is 0°. When the width is barely visible, the angle is approaching 90°.

宽度不变时,角度为0°。 当几乎看不到宽度时,角度接近90°。

As long as the target’s height remains the same, we can use the height and ratio to approximate the width at 0°. Therefore, we have the theoretical width, at 0°, and the actual width at x°. The actual width should always be less than the theoretical width because the width is greatest at 0°. Dividing the actual width by the theoretical width will yield a number between 0 and 1, representing the percent change in angle. Now we want to scale a number between 0 and 1 to a number between 0 and 90 to represent degrees.

只要目标的高度保持不变,我们就可以使用高度和比率近似于0°处的宽度。 因此,我们的理论宽度为0°,实际宽度为x°。 实际宽度应始终小于理论宽度,因为该宽度在0°处最大。 将实际宽度除以理论宽度将得到一个介于0和1之间的数字,代表角度的百分比变化。 现在我们要缩放0到1之间的数字到0到90之间的数字以表示度。

Because 1 represents zero change in width and 90° represents that there is no width, we subtract 1 by the ratio between actual width and theoretical width to get the opposite angle.

由于1表示宽度的零变化,而90°表示没有宽度,因此我们将实际宽度与理论宽度之比减去1以获得相反的角度。

Then, multiply that number by 90 to get an angle estimate between 0 and 90.

然后,将该数字乘以90,即可获得介于0到90之间的角度估计。

Simplified angle estimation equations:

简化的角度估算公式:

Angle = 1 — (actual width / ratio between width and height of target) * 90

角度 = 1-(实际宽度/目标宽度与高度的比率)* 90

Angle = (1 — (actual width * target height) / target width) * 90

角度 =(1-(实际宽度*目标高度)/目标宽度)* 90

That’s it! Now you can estimate the angle of a target relative to the camera.

而已! 现在,您可以估计目标相对于摄像机的角度。

Side note: This only works when the target’s height does not change, and when the target has distinct edges.

旁注:仅当目标的高度不变且目标具有明显的边缘时,此方法才有效。

试试演示! (Try the demo!)

Download the demo here!

在此处下载演示!

Using the demo, you can set a target color and enter the variables to get the distance and angle of the target object.

使用演示,您可以设置目标颜色并输入变量以获取目标对象的距离和角度。

回顾变量 (Recap of the variables)

Known Width: width of the object in any physical unit (Ex: cm, inches)

已知宽度:对象的宽度,以任何物理单位表示(例如:厘米,英寸)

Known Height: height of the object in any physical unit (Ex: cm, inches)

已知高度:物体在任何物理单位中的高度(例如:厘米,英寸)

Known distance from object: any distance from the camera to the object in the chosen unit above.

距物体的已知距离:从摄像机到上方所选单位的物体之间的任何距离。

Pixel height at above distance from camera: pixel height of the object when the distance is the same as the known distance from object.

距相机的距离以上的像素高度当距离与已知的距对象的距离相同时,对象的像素高度。

Image for post
Image for post

翻译自: https://medium.com/analytics-vidhya/how-to-track-distance-and-angle-of-an-object-using-opencv-1f1966d418b4

opencv实现对象跟踪

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

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

相关文章

spring cloud 入门系列七:基于Git存储的分布式配置中心--Spring Cloud Config

我们前面接触到的spring cloud组件都是基于Netflix的组件进行实现的,这次我们来看下spring cloud 团队自己创建的一个全新项目:Spring Cloud Config.它用来为分布式系统中的基础设施和微服务提供集中化的外部配置支持,分为服务端和客户端两个…

熊猫数据集_大熊猫数据框的5个基本操作

熊猫数据集Tips and Tricks for Data Science数据科学技巧与窍门 Pandas is a powerful and easy-to-use software library written in the Python programming language, and is used for data manipulation and analysis.Pandas是使用Python编程语言编写的功能强大且易于使用…

图嵌入综述 (arxiv 1709.07604) 译文五、六、七

应用 图嵌入有益于各种图分析应用,因为向量表示可以在时间和空间上高效处理。 在本节中,我们将图嵌入的应用分类为节点相关,边相关和图相关。 节点相关应用 节点分类 节点分类是基于从标记节点习得的规则,为图中的每个节点分配类标…

聊聊自动化测试框架

无论是在自动化测试实践,还是日常交流中,经常听到一个词:框架。之前学习自动化测试的过程中,一直对“框架”这个词知其然不知其所以然。 最近看了很多自动化相关的资料,加上自己的一些实践,算是对“框架”有…

移动磁盘文件或目录损坏且无法读取资料如何找回

文件或目录损坏且无法读取说明这个盘的文件系统结构损坏了。在平时如果数据不重要,那么可以直接格式化就能用了。但是有的时候里面的数据很重要,那么就必须先恢复出数据再格式化。具体恢复方法可以看正文了解(不格式化的恢复方法)…

python 平滑时间序列_时间序列平滑以实现更好的聚类

python 平滑时间序列In time series analysis, the presence of dirty and messy data can alter our reasonings and conclusions. This is true, especially in this domain, because the temporal dependency plays a crucial role when dealing with temporal sequences.在…

帮助学生改善学习方法_学生应该如何花费时间改善自己的幸福

帮助学生改善学习方法There have been numerous studies looking into the relationship between sleep, exercise, leisure, studying and happiness. The results were often quite like how we expected, though there have been debates about the relationship between sl…

Spring Boot 静态资源访问原理解析

一、前言 springboot配置静态资源方式是多种多样,接下来我会介绍其中几种方式,并解析一下其中的原理。 二、使用properties属性进行配置 应该说 spring.mvc.static-path-pattern 和 spring.resources.static-locations这两属性是成对使用的,如…

深挖“窄带高清”的实现原理

过去几年,又拍云一直在点播、直播等视频应用方面潜心钻研,取得了不俗的成果。我们结合点播、直播、短视频等业务中的用户场景,推出了“省带宽、压成本”系列文章,从编码技术、网络架构等角度出发,结合又拍云的产品成果…

Redis 服务安装

下载 客户端可视化工具: RedisDesktopManager redis官网下载: http://redis.io/download windos服务安装 windows服务安装/卸载下载文件并解压使用 管理员身份 运行命令行并且切换到解压目录执行 redis-service --service-install windowsR 打开运行窗口, 输入 services.msc 查…

熊猫数据集_对熊猫数据框使用逻辑比较

熊猫数据集P (tPYTHON) Logical comparisons are used everywhere.逻辑比较随处可见 。 The Pandas library gives you a lot of different ways that you can compare a DataFrame or Series to other Pandas objects, lists, scalar values, and more. The traditional comp…

决策树之前要不要处理缺失值_不要使用这样的决策树

决策树之前要不要处理缺失值As one of the most popular classic machine learning algorithm, the Decision Tree is much more intuitive than the others for its explainability. In one of my previous article, I have introduced the basic idea and mechanism of a Dec…

gl3520 gl3510_带有gl gl本机的跨平台地理空间可视化

gl3520 gl3510Editor’s note: Today’s post is by Ib Green, CTO, and Ilija Puaca, Founding Engineer, both at Unfolded, an “open core” company that builds products and services on the open source deck.gl / vis.gl technology stack, and is also a major contr…

uiautomator +python 安卓UI自动化尝试

使用方法基本说明:https://www.cnblogs.com/mliangchen/p/5114149.html,https://blog.csdn.net/Eugene_3972/article/details/76629066 环境准备:https://www.cnblogs.com/keeptheminutes/p/7083816.html 简单实例 1.自动化安装与卸载 &#…

power bi中的切片器_在Power Bi中显示选定的切片器

power bi中的切片器Just recently, while presenting my session: “Magnificent 7 — Simple tricks to boost your Power BI Development” at the New Stars of Data conference, one of the questions I’ve received was:就在最近,在“新数据之星”会议上介绍我…

5939. 半径为 k 的子数组平均值

5939. 半径为 k 的子数组平均值 给你一个下标从 0 开始的数组 nums ,数组中有 n 个整数,另给你一个整数 k 。 半径为 k 的子数组平均值 是指:nums 中一个以下标 i 为 中心 且 半径 为 k 的子数组中所有元素的平均值,即下标在 i …

数据库逻辑删除的sql语句_通过数据库的眼睛查询sql的逻辑流程

数据库逻辑删除的sql语句Structured Query Language (SQL) is famously known as the romance language of data. Even thinking of extracting the single correct answer from terabytes of relational data seems a little overwhelming. So understanding the logical flow…

数据挖掘流程_数据流挖掘

数据挖掘流程1-简介 (1- Introduction) The fact that the pace of technological change is at its peak, Silicon Valley is also introducing new challenges that need to be tackled via new and efficient ways. Continuous research is being carried out to improve th…

北门外的小吃街才是我的大学食堂

学校北门外的那些小吃摊,陪我度过了漫长的大学四年。 细数下来,我最怀念的是…… (1)烤鸡翅 吸引指数:★★★★★ 必杀技:酥流油 烤鸡翅有蜂蜜味、香辣味、孜然味……最爱店家独创的秘制鸡翅。鸡翅的外皮被…

[LeetCode]最长公共前缀(Longest Common Prefix)

题目描述 编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀,返回空字符串 ""。 示例 1:输入: ["flower","flow","flight"]输出: "fl"示例 2:输入: ["dog","racecar",&quo…