日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

python opencv3 检测人

發(fā)布時(shí)間:2024/7/19 python 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python opencv3 检测人 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

?git:https://github.com/linyi0604/Computer-Vision?

?

1 # coding:utf-8 2 3 import cv2 4 5 6 # 檢測(cè)i方框 包含o方框 7 def is_inside(o, i): 8 ox, oy, ow, oh = o 9 ix, iy, iw, ih = i 10 return ox > ix and ox + ow < ix + iw and oy + oh < iy + ih 11 12 13 # 將人外面的方框畫(huà)出來(lái) 14 def draw_person(image, person): 15 x, y, w, h = person 16 cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 255), 2) 17 18 19 # 讀入圖片 20 img = cv2.imread("../data/people2.jpg") 21 # 獲取hog檢測(cè)器對(duì)象 22 hog = cv2.HOGDescriptor() 23 # 設(shè)置檢測(cè)人的默認(rèn)檢測(cè)器 24 hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector()) 25 # 在圖片中檢測(cè)人, 26 # 返回found列表 每個(gè)元素是一個(gè)(x, y, w, h)的矩形,w是每一個(gè)矩形的置信度 27 found, w = hog.detectMultiScale(img) 28 found_filtered = [] 29 # 如果方框有包含,只留下內(nèi)部的小方塊 30 for ri, r in enumerate(found): 31 for qi, q in enumerate(found): 32 if ri != qi and is_inside(r, q): 33 break 34 else: 35 found_filtered.append(r) 36 37 # 將每一個(gè)方塊畫(huà)出來(lái) 38 for person in found_filtered: 39 draw_person(img, person) 40 41 42 cv2.imshow("person detection", img) 43 cv2.waitKey() 44 cv2.destroyAllWindows()

?

?

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/Lin-Yi/p/9443924.html

總結(jié)

以上是生活随笔為你收集整理的python opencv3 检测人的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。