1 Star 0 Fork 3

yw960/HeadShot

forked from Cybersh1t/HeadShot 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
test.py 692 Bytes
一键复制 编辑 原始数据 按行查看 历史
Cybersh1t 提交于 2021-11-02 19:08 . Gradient Aimimg Update
import cv2
import numpy as np
lower = np.array([89, 120, 168])
upper = np.array([95, 255, 255])
img = cv2.imread('test4.png')
screen_temp = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
mask = cv2.inRange(screen_temp, lower, upper)
contours, hier = cv2.findContours(mask, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
for c in contours:
# find bounding box coordinates
x, y, w, h = cv2.boundingRect(c)
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
# calculate coordinates of the minimum area rectangle
print(len(contours))
cv2.drawContours(img, contours, -1, (255, 0, 0), 1)
while True:
cv2.imshow("contours", img)
if cv2.waitKey(10) & 0xFF == ord('q'):
break
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yw960/head-shot.git
git@gitee.com:yw960/head-shot.git
yw960
head-shot
HeadShot
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385