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.pswp.cn/news/389649.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389649.shtml
英文地址,請注明出處:http://en.pswp.cn/news/389649.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

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

我們前面接觸到的spring cloud組件都是基于Netflix的組件進行實現的,這次我們來看下spring cloud 團隊自己創建的一個全新項目:Spring Cloud Config.它用來為分布式系統中的基礎設施和微服務提供集中化的外部配置支持,分為服務端和客戶端兩個…

458. 可憐的小豬

458. 可憐的小豬 有 buckets 桶液體,其中 正好 有一桶含有毒藥,其余裝的都是水。它們從外觀看起來都一樣。為了弄清楚哪只水桶含有毒藥,你可以喂一些豬喝,通過觀察豬是否會死進行判斷。不幸的是,你只有 minutesToTest…

熊貓數據集_大熊貓數據框的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) 譯文五、六、七

應用 圖嵌入有益于各種圖分析應用,因為向量表示可以在時間和空間上高效處理。 在本節中,我們將圖嵌入的應用分類為節點相關,邊相關和圖相關。 節點相關應用 節點分類 節點分類是基于從標記節點習得的規則,為圖中的每個節點分配類標…

聊聊自動化測試框架

無論是在自動化測試實踐,還是日常交流中,經常聽到一個詞:框架。之前學習自動化測試的過程中,一直對“框架”這個詞知其然不知其所以然。 最近看了很多自動化相關的資料,加上自己的一些實踐,算是對“框架”有…

1971. Find if Path Exists in Graph

1971. Find if Path Exists in Graph 有一個具有 n個頂點的 雙向 圖,其中每個頂點標記從 0 到 n - 1(包含 0 和 n - 1)。圖中的邊用一個二維整數數組 edges 表示,其中 edges[i] [ui, vi] 表示頂點 ui 和頂點 vi 之間的雙向邊。 …

移動磁盤文件或目錄損壞且無法讀取資料如何找回

文件或目錄損壞且無法讀取說明這個盤的文件系統結構損壞了。在平時如果數據不重要,那么可以直接格式化就能用了。但是有的時候里面的數據很重要,那么就必須先恢復出數據再格式化。具體恢復方法可以看正文了解(不格式化的恢復方法)…

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.在…

基于SmartQQ協議的QQ自動回復機器人-1

0. 本項目的原始代碼及我二次開發后的代碼 1. 軟件安裝:【myeclipse6.0 maven2】 0. https://blog.csdn.net/zgmzyr/article/details/6886440 1. https://blog.csdn.net/shuzhe66/article/details/45009175 2. https://www.cnblogs.com/whgk/p/7112560.html<mirror><…

1725. 可以形成最大正方形的矩形數目

1725. 可以形成最大正方形的矩形數目 給你一個數組 rectangles &#xff0c;其中 rectangles[i] [li, wi] 表示第 i 個矩形的長度為 li 、寬度為 wi 。 如果存在 k 同時滿足 k < li 和 k < wi &#xff0c;就可以將第 i 個矩形切成邊長為 k 的正方形。例如&#xff0c…

幫助學生改善學習方法_學生應該如何花費時間改善自己的幸福

幫助學生改善學習方法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配置靜態資源方式是多種多樣&#xff0c;接下來我會介紹其中幾種方式&#xff0c;并解析一下其中的原理。 二、使用properties屬性進行配置 應該說 spring.mvc.static-path-pattern 和 spring.resources.static-locations這兩屬性是成對使用的&#xff0c;如…

深挖“窄帶高清”的實現原理

過去幾年&#xff0c;又拍云一直在點播、直播等視頻應用方面潛心鉆研&#xff0c;取得了不俗的成果。我們結合點播、直播、短視頻等業務中的用戶場景&#xff0c;推出了“省帶寬、壓成本”系列文章&#xff0c;從編碼技術、網絡架構等角度出發&#xff0c;結合又拍云的產品成果…

學習總結5 - bootstrap學習記錄1__安裝

1.bootstrap是什么&#xff1f; 簡潔、直觀、強悍的前端開發框架&#xff0c;說白了就是給后端二把刀開發網頁用的&#xff0c;讓web開發更迅速、簡單。 復制代碼 2.如何使用&#xff1f; 如圖所示到bootstrap中文網進行下載 復制代碼 下載完成之后&#xff0c;如圖所示&#x…

519. 隨機翻轉矩陣

519. 隨機翻轉矩陣 給你一個 m x n 的二元矩陣 matrix &#xff0c;且所有值被初始化為 0 。請你設計一個算法&#xff0c;隨機選取一個滿足 matrix[i][j] 0 的下標 (i, j) &#xff0c;并將它的值變為 1 。所有滿足 matrix[i][j] 0 的下標 (i, j) 被選取的概率應當均等。 …

模型的搜索和優化方法綜述:

一、常用的優化方法&#xff1a; 1.爬山 2.最陡峭下降 3.期望最大值 二、常用的搜索方法&#xff1a; 1.貪婪搜索 2.分支界定 3.寬度&#xff08;深度&#xff09;優先遍歷轉載于:https://www.cnblogs.com/xyp666/p/9042143.html

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…

初級功能筆試題-1

給我徒弟整理的一些理論性的筆試題&#xff0c;不喜勿噴。&#xff08;所以沒有答案哈&#xff09; 1、測試人員返測缺陷時&#xff0c;如果缺陷未修復&#xff0c;把缺陷的狀態置為下列什么狀態&#xff08;&#xff09;。 2、當驗證被測系統的主要業務流程和功能是否實現時&a…

ansbile--playbook劇本案例

個人博客轉至&#xff1a; www.zhangshoufu.com 通過ansible批量管理三臺服務器&#xff0c;使三臺服務器實現備份&#xff0c;web01、nfs、backup&#xff0c;把web和nfs上的重要文件被分到backup上&#xff0c;主機ip地址分配如下 CharacterIP地址IP地址主機名Rsync--server1…