Python計(jì)算機(jī)視覺里的IOU計(jì)算實(shí)例
更新時(shí)間:2020年01月17日 10:25:56 作者:GAN_player
今天小編就為大家分享一篇Python計(jì)算機(jī)視覺里的IOU計(jì)算實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
其中x1,y1;x2,y2分別表示兩個(gè)矩形框的中心點(diǎn)
def calcIOU(x1, y1, w1, h1, x2, y2, w2, h2):
if((abs(x1 - x2) < ((w1 + w2)/ 2.0)) and (abs(y1-y2) < ((h1 + h2)/2.0))):
left = max((x1 - (w1 / 2.0)), (x2 - (w2 / 2.0)))
upper = max((y1 - (h1 / 2.0)), (y2 - (h2 / 2.0)))
right = min((x1 + (w1 / 2.0)), (x2 + (w2 / 2.0)))
bottom = min((y1 + (h1 / 2.0)), (y2 + (h2 / 2.0)))
inter_w = abs(left - right)
inter_h = abs(upper - bottom)
inter_square = inter_w * inter_h
union_square = (w1 * h1)+(w2 * h2)-inter_square
calcIOU = inter_square/union_square * 1.0
print("calcIOU:", calcIOU)
else:
print("No intersection!")
return calcIOU
def main():
calcIOU(1, 2, 2, 2, 2, 1, 2, 2)
if __name__ == '__main__':
main()
以上這篇Python計(jì)算機(jī)視覺里的IOU計(jì)算實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Python實(shí)現(xiàn)灰色關(guān)聯(lián)分析與結(jié)果可視化的詳細(xì)代碼
今天小編通過代碼以灰色色系為例給大家介紹Python灰色關(guān)聯(lián)分析實(shí)現(xiàn)方法,灰色關(guān)聯(lián)度分析對(duì)于一個(gè)系統(tǒng)發(fā)展變化態(tài)勢提供了量化的度量,非常適合動(dòng)態(tài)歷程分析,感興趣的朋友一起看看吧2022-03-03
python3 使用openpyxl將mysql數(shù)據(jù)寫入xlsx的操作
這篇文章主要介紹了python3 使用openpyxl將mysql數(shù)據(jù)寫入xlsx的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-05-05
Python實(shí)現(xiàn)的爬取豆瓣電影信息功能案例
這篇文章主要介紹了Python實(shí)現(xiàn)的爬取豆瓣電影信息功能,結(jié)合具體實(shí)例形式分析了Python基于requests庫的爬蟲使用技巧,需要的朋友可以參考下2019-09-09
Python實(shí)現(xiàn)合并excel表格的方法分析
這篇文章主要介紹了Python實(shí)現(xiàn)合并excel表格的方法,結(jié)合實(shí)例形式分析了Python合并Excel表格的原理、實(shí)現(xiàn)步驟與相關(guān)操作技巧,需要的朋友可以參考下2019-04-04

