目录
前言
课题背景和意义
实现技术思路
数据来源
COCO数据集预训练模型
图片检测
视频检测
训练&评估结果
实现效果图样例
📅大四是整个大学期间最忙碌的时光,一边要忙着备考或实习为毕业后面临的就业升学做准备,一边要为毕业设计耗费大量精力。近几年各个学校要求的毕设项目越来越难,有不少课题是研究生级别难度的,对本科同学来说是充满挑战。为帮助大家顺利通过和节省时间与精力投入到更重要的就业和考试中去,学长分享优质的选题经验和毕设项目与技术思路。
🚀对毕设有任何疑问都可以问学长哦!
本次分享的课题是
🎯基于机器视觉的口罩佩戴检测识别
疫情期间,有一个关键点就是春节之后的复工。在国内有一个特殊的情况,就是在复工的时候,人员流动量相当庞大。肺炎疫情仍在持续,佩戴口罩是预防感染的有效措施,目前很多公众场合要求强制佩戴口罩,检测人物是否佩戴口罩。软件可以检测摄像头视频中的人是否佩戴口罩。进行口罩数据集训练,达到检测人群中有无戴口罩的目的。

COCO数据集全称为Microsoft Common Objects in Context(MS COCO),它是一个大规模(large-scale)的对象检测(object detection)、分割(segmentation)、关键点检测(key-point detection)和字幕(captioning)数据集。此数据集由32.8万张图像组成.COCO API可以帮助加载、解析和可视化COCO中的标注。API支持多种标注格式(annotation formats)。
def detect_image(image_path):print('Start detect!')yolo = YOLO()try:image = Image.open(image_path)except:print('Open Error! Try again!')passelse:r_image = yolo.detect_image(image)r_image.save(image_path.split('.')[0] + '_result.png')print('Finish detect!')
def detect_video(video_path):print('Start detect!')yolo = YOLO()capture = cv2.VideoCapture(video_path)writer = Nonefps = 0.0while True:t1 = time.time()# 读取某一帧grabbed, frame = capture.read()if not grabbed:break# opencv读取的是BGR,格式转变,BGRtoRGBframe = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)# 转变成Imageframe = Image.fromarray(np.uint8(frame))# 进行检测frame = np.array(yolo.detect_image(frame))# RGBtoBGR满足opencv显示格式frame = cv2.cvtColor(frame,cv2.COLOR_RGB2BGR)fps = (fps + (1. / (time.time() - t1))) / 2print("FPS: %.2f" % (fps))frame = cv2.putText(frame, "FPS: %.2f" % (fps), (0, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 2, cv2.LINE_AA)if writer is None:fourcc = cv2.VideoWriter_fourcc(*'MP4V')writer = cv2.VideoWriter(video_path.split('.')[0] + '_result.mp4', fourcc, 30, (frame.shape[1], frame.shape[0]), True)writer.write(frame)writer.release()capture.release()print('Finish detect!')



我是海浪学长,创作不易,欢迎点赞、关注、收藏、留言。
毕设帮助,疑难解答,欢迎打扰!