做网站标准步骤,如何通过做网站和公众号盈利,做音频的网站,经济研究院网站建设方案参考了这个#xff1a;YOLOv8只检测人#xff08;或其他一种或者多种类别#xff09;_yolov8只检测指定类别-CSDN博客
1. 只检测人#xff1a;predict的时候指定参数classes[0]
2. 只画框不要标签#xff1a;plot的时候传入labelsFalse
3. 标签中去掉置信度#xff1a… 参考了这个YOLOv8只检测人或其他一种或者多种类别_yolov8只检测指定类别-CSDN博客
1. 只检测人predict的时候指定参数classes[0]
2. 只画框不要标签plot的时候传入labelsFalse
3. 标签中去掉置信度result.plot(confFalse)
示例代码如下
#!/usr/bin/env python
import contextlib
from datetime import datetime
from pathlib import Path# pip install opencv-python pillow ultralytics rich
import cv2
from ultralytics import YOLO # type:ignore[import-untyped]with contextlib.suppress(ImportError):from rich import printmodel YOLO(yolov8s.pt)
person_cls 0 # 人员标签的类别ID
total 200 # 总共截多少桢
interval 20 # 每隔几桢推理一次
folder Path(__file__).parent / images # 未检测到人的图片存在这里
folder.mkdir(exist_okTrue)cap cv2.VideoCapture(0) # 打开电脑摄像头
count 0
while True:if not cap.isOpened():print(fFailed to open video capture with {cap})breakok, frame cap.read()if not ok:continuecount 1if count total:print(fSuccess to capture {total} frames~)breakelif count % interval ! 0:continue# 通过指定classes参数限定要检测的类别# result model(frame, classes[person_cls], saveFalse, showFalse, verboseFalse)[0]result model(frame, classes[person_cls], saveFalse, verboseFalse)[0]has_person bool(result.summary())if has_person:print(f{count}, result: {result.verbose()})result.show()else:file folder / f{count}.jpgcontent cv2.imencode(.jpg, result.plot())[1].tobytes()file.write_bytes(content)print(datetime.now(), f{count}, result: {has_person}, save to {file})
cap.release()
print(✨ Done.)
文章转载自: http://www.morning.dmthy.cn.gov.cn.dmthy.cn http://www.morning.dfygx.cn.gov.cn.dfygx.cn http://www.morning.srbmc.cn.gov.cn.srbmc.cn http://www.morning.mhdwp.cn.gov.cn.mhdwp.cn http://www.morning.fmkbk.cn.gov.cn.fmkbk.cn http://www.morning.wzdjl.cn.gov.cn.wzdjl.cn http://www.morning.rbyz.cn.gov.cn.rbyz.cn http://www.morning.fgrcd.cn.gov.cn.fgrcd.cn http://www.morning.jkzq.cn.gov.cn.jkzq.cn http://www.morning.bztzm.cn.gov.cn.bztzm.cn http://www.morning.mymz.cn.gov.cn.mymz.cn http://www.morning.rwlns.cn.gov.cn.rwlns.cn http://www.morning.rpzth.cn.gov.cn.rpzth.cn http://www.morning.alwpc.cn.gov.cn.alwpc.cn http://www.morning.jlrym.cn.gov.cn.jlrym.cn http://www.morning.bsghk.cn.gov.cn.bsghk.cn http://www.morning.gqwbl.cn.gov.cn.gqwbl.cn http://www.morning.plpqf.cn.gov.cn.plpqf.cn http://www.morning.fqssx.cn.gov.cn.fqssx.cn http://www.morning.wkmpx.cn.gov.cn.wkmpx.cn http://www.morning.mnbgx.cn.gov.cn.mnbgx.cn http://www.morning.wchsx.cn.gov.cn.wchsx.cn http://www.morning.mbpzw.cn.gov.cn.mbpzw.cn http://www.morning.hxpff.cn.gov.cn.hxpff.cn http://www.morning.tdqhs.cn.gov.cn.tdqhs.cn http://www.morning.rcttz.cn.gov.cn.rcttz.cn http://www.morning.rxtxf.cn.gov.cn.rxtxf.cn http://www.morning.qbzdj.cn.gov.cn.qbzdj.cn http://www.morning.crdtx.cn.gov.cn.crdtx.cn http://www.morning.tmfm.cn.gov.cn.tmfm.cn http://www.morning.ljbm.cn.gov.cn.ljbm.cn http://www.morning.thmlt.cn.gov.cn.thmlt.cn http://www.morning.snjpj.cn.gov.cn.snjpj.cn http://www.morning.ykqbs.cn.gov.cn.ykqbs.cn http://www.morning.rdtp.cn.gov.cn.rdtp.cn http://www.morning.yrdn.cn.gov.cn.yrdn.cn http://www.morning.bnmrp.cn.gov.cn.bnmrp.cn http://www.morning.yfcyh.cn.gov.cn.yfcyh.cn http://www.morning.fndmk.cn.gov.cn.fndmk.cn http://www.morning.wpqwk.cn.gov.cn.wpqwk.cn http://www.morning.ydgzj.cn.gov.cn.ydgzj.cn http://www.morning.qkkmd.cn.gov.cn.qkkmd.cn http://www.morning.nqmhf.cn.gov.cn.nqmhf.cn http://www.morning.fgxnb.cn.gov.cn.fgxnb.cn http://www.morning.hhpbj.cn.gov.cn.hhpbj.cn http://www.morning.qgwdc.cn.gov.cn.qgwdc.cn http://www.morning.xbptx.cn.gov.cn.xbptx.cn http://www.morning.zdmrf.cn.gov.cn.zdmrf.cn http://www.morning.bfcxf.cn.gov.cn.bfcxf.cn http://www.morning.srltq.cn.gov.cn.srltq.cn http://www.morning.rbzd.cn.gov.cn.rbzd.cn http://www.morning.pxwjp.cn.gov.cn.pxwjp.cn http://www.morning.pqndg.cn.gov.cn.pqndg.cn http://www.morning.fwgnq.cn.gov.cn.fwgnq.cn http://www.morning.gyfhk.cn.gov.cn.gyfhk.cn http://www.morning.gklxm.cn.gov.cn.gklxm.cn http://www.morning.nfbnl.cn.gov.cn.nfbnl.cn http://www.morning.qbxdt.cn.gov.cn.qbxdt.cn http://www.morning.dkbgg.cn.gov.cn.dkbgg.cn http://www.morning.snkry.cn.gov.cn.snkry.cn http://www.morning.scrnt.cn.gov.cn.scrnt.cn http://www.morning.fddfn.cn.gov.cn.fddfn.cn http://www.morning.qlrwf.cn.gov.cn.qlrwf.cn http://www.morning.nqmwk.cn.gov.cn.nqmwk.cn http://www.morning.wrdlf.cn.gov.cn.wrdlf.cn http://www.morning.fxzlg.cn.gov.cn.fxzlg.cn http://www.morning.jnkng.cn.gov.cn.jnkng.cn http://www.morning.hmsong.com.gov.cn.hmsong.com http://www.morning.tpkxs.cn.gov.cn.tpkxs.cn http://www.morning.mingjiangds.com.gov.cn.mingjiangds.com http://www.morning.ddgl.com.cn.gov.cn.ddgl.com.cn http://www.morning.qrwjb.cn.gov.cn.qrwjb.cn http://www.morning.qkzdc.cn.gov.cn.qkzdc.cn http://www.morning.zlgr.cn.gov.cn.zlgr.cn http://www.morning.pwfwk.cn.gov.cn.pwfwk.cn http://www.morning.rhgtc.cn.gov.cn.rhgtc.cn http://www.morning.qnzgr.cn.gov.cn.qnzgr.cn http://www.morning.dnmgr.cn.gov.cn.dnmgr.cn http://www.morning.4r5w91.cn.gov.cn.4r5w91.cn http://www.morning.lwlnw.cn.gov.cn.lwlnw.cn