在Yolov5中使用Mediapipe实现对手部特定范围检测
实现效果如下图所示
使用Yolov5-Mediapipe能够根据手部的坐标变化,实时实现Yolo只对于手部周围检测框内物体的检测,该代码的实现使用的是Yolov5-6.0,链接为https://github.com/ultralytics/yolov5/tags 使用的权重为yolov5s.pt
Yolov5
效果
代码
detect.py
由于yolo是逐帧运行的,需要detect在每次获取到手部数据以后需要在Loadstream代码块中对于相机捕获到的手部数据更新
// detect.py
# Dataloader
if webcam:
view_img = check_imshow()
cudnn.benchmark = True # set True to speed up constant image size inference
dataset = LoadStreams(source, img_size=imgsz, stride=stride, auto=pt)
bs = len(dataset) # batch_size