张家口市网站建设_网站建设公司_CSS_seo优化
2025/12/18 12:36:03 网站建设 项目流程

博主介绍:✌全网粉丝10W+,前互联网大厂软件研发、集结硕博英豪成立工作室。专注于计算机相关专业项目实战6年之久,选择我们就是选择放心、选择安心毕业✌
> 🍅想要获取完整文章或者源码,或者代做,拉到文章底部即可与我联系了。🍅

点击查看作者主页,了解更多项目!

🍅感兴趣的可以先收藏起来,点赞、关注不迷路,大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助同学们顺利毕业 。🍅

1、毕业设计:2026年计算机专业毕业设计选题汇总(建议收藏)✅

2、大数据毕业设计:2026年选题大全 深度学习 python语言 JAVA语言 hadoop和spark(建议收藏)✅

🍅感兴趣的可以先收藏起来,点赞、关注不迷路,大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助同学们顺利毕业 。🍅

1、项目介绍

技术栈:
Python语言、YOLOv5模型、PyQt5界面、openCV、tensorflow、torch

停车位检测系统是指利用计算机视觉技术对停车场内的停车位进行实时监测和识别,以便为车主提供及时准确的空余停车位信息。停车位检测系统主要包括两个主要组成部分:硬件和软件。硬件方面,停车位检测系统需要使用摄像头或传感器等设备对停车场进行实时监测,以获取停车位的状态信息。软件方面,停车位检测系统需要使用计算机视觉技术对摄像头或传感器拍摄的图像进行分析和处理,以实现停车位的检测和识别。停车位检测系统的主要功能包括实时监测停车场内的停车位,精准识别车位状态,即刻提供车位空余信息,提高停车场的利用效率,减少车主的停车等待时间,缓解停车位紧张问题,改善城市停车环境,提高城市交通管理水平等。停车位检测系统在智慧城市建设、交通管理、商业运营等领域具有广泛的应用前景。同时,停车位检测系统还可以结合车辆管理系统、支付系统等其他系统,实现更加智能化的停车场管理和服务。

停车位检测系统基于机器视觉深度学习技术能够实现无人值守的不间断工作,并且系统可以主动发现监控区域内的空闲停车位情况;极大的节约了人员成本,提高了工作效率。这里给出博主设计的软件界面,同款的简约风,功能也可以满足图片、视频和摄像头的识别检测

2、项目界面

(1)停车位实时检测识别-----已泊车、空车位

(2)停车位实时检测识别-----选择其中一个空车位

(3)上传图片检测识别

(4)上传视频检测识别

(6)摄像头或视频实时检测

(8)摄像头或视频实时检测

(9)系统首页

3、项目说明

停车位检测系统是指利用计算机视觉技术对停车场内的停车位进行实时监测和识别,以便为车主提供及时准确的空余停车位信息。停车位检测系统主要包括两个主要组成部分:硬件和软件。硬件方面,停车位检测系统需要使用摄像头或传感器等设备对停车场进行实时监测,以获取停车位的状态信息。软件方面,停车位检测系统需要使用计算机视觉技术对摄像头或传感器拍摄的图像进行分析和处理,以实现停车位的检测和识别。停车位检测系统的主要功能包括实时监测停车场内的停车位,精准识别车位状态,即刻提供车位空余信息,提高停车场的利用效率,减少车主的停车等待时间,缓解停车位紧张问题,改善城市停车环境,提高城市交通管理水平等。停车位检测系统在智慧城市建设、交通管理、商业运营等领域具有广泛的应用前景。同时,停车位检测系统还可以结合车辆管理系统、支付系统等其他系统,实现更加智能化的停车场管理和服务。

停车位检测系统基于机器视觉深度学习技术能够实现无人值守的不间断工作,并且系统可以主动发现监控区域内的空闲停车位情况;极大的节约了人员成本,提高了工作效率。这里给出博主设计的软件界面,同款的简约风,功能也可以满足图片、视频和摄像头的识别检测

4、核心代码

importargparseimportosimportrandomimporttimefromosimportgetcwdimportcv2importnumpyasnpimporttorchfromPyQt5importQtCore,QtWidgetsfromPyQt5.QtWidgetsimportQFileDialog,QMessageBoxfromParkingSpaces.label_nameimportChinese_namefrommodels.experimentalimportattempt_loadfromutilsimportQMainWindowfromutils.datasetsimportletterboxfromutils.generalimport(check_img_size,non_max_suppression,scale_coords)fromutils.torch_utilsimportselect_device,time_synchronized# 忽略警告# os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"# warnings.filterwarnings(action='ignore')classParkingSpace_MainWindow(QMainWindow):def__init__(self,*args,obj=None,**kwargs):super(ParkingSpace_MainWindow,self).__init__(*args,**kwargs)self.author_flag=False# 是否输出信息 试一下# self.pass_flag = True # 是否需要跳过登录界面self.setupUi(self)# 界面生成self.retranslateUi(self)# 界面控件self.setUiStyle(window_flag=True,transBack_flag=True)# 设置界面样式self.path=getcwd()self.video_path=getcwd()self.timer_camera=QtCore.QTimer()# 定时器self.timer_video=QtCore.QTimer()# 视频定时器self.flag_timer=""# 用于标记正在进行的功能项(视频/摄像)self.LoadModel()# 加载预训练模型self.slot_init()# 定义槽函数self.files=[]#self.cap_video=None# 视频流对象self.CAM_NUM=0# 摄像头标号self.cap=cv2.VideoCapture(self.CAM_NUM)# 屏幕画面对象self.detInfo=[]self.current_image=[]self.detected_image=None# self.dataset = Noneself.count=0# 表格行数,用于记录识别识别条目self.res_set=[]# 用于历史结果记录的列表self.c_video=0self.count_name=["空车位","已泊车"]self.count_table=[]# self.plotBar(self.count_name, [0 for i in self.count_name], self.colors, margin=30)defslot_init(self):self.toolButton_file.clicked.connect(self.choose_file)self.toolButton_folder.clicked.connect(self.choose_folder)self.toolButton_video.clicked.connect(self.button_open_video_click)self.timer_video.timeout.connect(self.show_video)self.toolButton_camera.clicked.connect(self.button_open_camera_click)self.timer_camera.timeout.connect(self.show_camera)self.toolButton_model.clicked.connect(self.choose_model)self.comboBox_select.currentIndexChanged.connect(self.select_obj)self.tableWidget.cellPressed.connect(self.table_review)self.toolButton_saveing.clicked.connect(self.save_file)self.toolButton_settings.clicked.connect(self.setting)self.toolButton_author.clicked.connect(self.disp_website)self.toolButton_version.clicked.connect(self.disp_version)deftable_review(self,row,col):try:ifcol==0:# 点击第一列时this_path=self.tableWidget.item(row,1)# 表格中的文件路径res=self.tableWidget.item(row,2)# 表格中记录的识别结果axes=self.tableWidget.item(row,3)# 表格中记录的坐标if(this_pathisnotNone)&(resisnotNone)&(axesisnotNone):this_path=this_path.text()ifos.path.exists(this_path):res=res.text()axes=axes.text()image=self.cv_imread(this_path)# 读取选择的图片image=cv2.resize(image,(850,500))axes=[int(i)foriinaxes.split(",")]confi=float(self.tableWidget.item(row,4).text())# print(axes)# image = self.drawRectBox(image, axes, res)count=self.count_table[row]# self.plotBar(self.count_name, count, self.colors, margin=30)self.label_numer_result.setText(str(sum(count)))image=self.drawRectEdge(image,axes,alpha=0.2,addText=res)# 在Qt界面中显示检测完成画面self.display_image(image)# 在界面中显示画面# 在界面标签中显示结果self.label_xmin_result.setText(str(int(axes[0])))self.label_ymin_result.setText(str(int(axes[1])))self.label_xmax_result.setText(str(int(axes[2])))self.label_ymax_result.setText(str(int(axes[3])))self.label_score_result.setText(str(round(confi*100,2))+"%")self.label_class_result.setText(res)QtWidgets.QApplication.processEvents()except:self.label_display.setText('重现表格记录时出错,请检查表格内容!')self.label_display.setStyleSheet("border-image: url(:/newPrefix/images_test/ini-image.png);")defLoadModel(self,model_path=None):""" 读取预训练模型 """parser=argparse.ArgumentParser()parser.add_argument('--weights',nargs='+',type=str,default='./weights/parking-best.pt',help='model.pt path(s)')# 模型路径仅支持.pt文件parser.add_argument('--img-size',type=int,default=480,help='inference size (pixels)')# 检测图像大小,仅支持480parser.add_argument('--conf-thres',type=float,default=0.25,help='object confidence threshold')# 置信度阈值parser.add_argument('--iou-thres',type=float,default=0.45,help='IOU threshold for NMS')# NMS阈值# 选中运行机器的GPU或者cpu,有GPU则GPU,没有则cpu,若想仅使用cpu,可以填cpu即可parser.add_argument('--device',default='',help='cuda device, i.e. 0 or 0,1,2,3 or cpu')parser.add_argument('--save-dir',type=str,default='inference',help='directory to save results')# 文件保存路径parser.add_argument('--classes',nargs='+',type=int,help='filter by class: --class 0, or --class 0 2 3')# 分开类别parser.add_argument('--agnostic-nms',action='store_true',help='class-agnostic NMS')# 使用NMSself.opt=parser.parse_args()# opt局部变量,重要out,weight,imgsz=self.opt.save_dir,self.opt.weights,self.opt.img_size# 得到文件保存路径,文件权重路径,图像尺寸self.device=select_device(self.opt.device)# 检验计算单元,gpu还是cpuself.half=self.device.type!='cpu'# 如果使用gpu则进行半精度推理ifmodel_path:weight=model_path self.model=attempt_load(weight,map_location=self.device)# 读取模型self.imgsz=check_img_size(imgsz,s=self.model.stride.max())# 检查图像尺寸ifself.half:# 如果是半精度推理self.model.half()# 转换模型的格式self.names=self.model.module.namesifhasattr(self.model,'module')elseself.model.names# 得到模型训练的类别名# self.names = [Chinese_name[i] for i in self.names]fori,vinenumerate(self.names):ifvinChinese_name.keys():self.names[i]=Chinese_name[v]# hex = ('FF3838', 'FF9D97', 'FF701F', 'FFB21D', 'CFD231', '48F90A', '92CC17', '3DDB86', '1A9334', '00D4BB',# '2C99A8', '00C2FF', '344593', '6473FF', '0018EC', '8438FF', '520085', 'CB38FF', 'FF95C8', 'FF37C7')color=[[132,56,255],[82,0,133],[203,56,255],[255,149,200],[255,55,199],[72,249,10],[146,204,23],[61,219,134],[26,147,52],[0,212,187],[255,56,56],[255,157,151],[255,112,31],[255,178,29],[207,210,49],[44,153,168],[0,194,255],[52,69,147],[100,115,255],[0,24,236]]self.colors=coloriflen(self.names)<=len(color)else[[random.randint(0,255)for_inrange(3)]for_inrange(len(self.names))]# 给每个类别一个颜色img=torch.zeros((1,3,self.imgsz,self.imgsz),device=self.device)# 创建一个图像进行预推理_=self.model(img.half()ifself.halfelseimg)ifself.device.type!='cpu'elseNone# 预推理defchoose_model(self):self.timer_camera.stop()self.timer_video.stop()ifself.capandself.cap.isOpened():self.cap.release()ifself.cap_video:self.cap_video.release()# 释放视频画面帧self.comboBox_select.clear()# 下拉选框的显示self.comboBox_select.addItem('所有目标')# 清除下拉选框self.clearUI()# 清除UI上的label显示self.flag_timer=""# 调用文件选择对话框fileName_choose,filetype=QFileDialog.getOpenFileName(self.centralwidget,"选取图片文件",getcwd(),# 起始路径"Model File (*.pt)")# 文件类型# 显示提示信息iffileName_choose!='':self.toolButton_model.setToolTip(fileName_choose+' 已选中')else:fileName_choose=None# 模型默认路径self.toolButton_model.setToolTip('使用默认模型')self.LoadModel(fileName_choose)defselect_obj(self):QtWidgets.QApplication.processEvents()ifself.flag_timer=="video":# 打开定时器self.timer_video.start(30)elifself.flag_timer=="camera":self.timer_camera.start(30)ind=self.comboBox_select.currentIndex()-1ind_select=indifind<=-1:ind_select=0# else:# ind_select = len(self.detInfo) - ind - 1iflen(self.detInfo)>0:# self.label_class_result.setFont(font)self.label_class_result.setText(self.detInfo[ind_select][0])# 显示类别self.label_score_result.setText(str(self.detInfo[ind_select][2]))# 显示置信度值# 显示位置坐标self.label_xmin_result.setText(str(int(self.detInfo[ind_select][1][0])))self.label_ymin_result.setText(str(int(self.detInfo[ind_select][1][1])))self.label_xmax_result.setText(str(int(self.detInfo[ind_select][1][2])))self.label_ymax_result.setText(str(int(self.detInfo[ind_select][1][3])))image=self.current_image.copy()iflen(self.detInfo)>0:fori,boxinenumerate(self.detInfo):# 遍历所有标记框ifind!=-1:ifind!=i:continue# 在图像上标记目标框label='%s %.0f%%'%(box[0],float(box[2])*100)self.label_score_result.setText(box[2])# label = str(box[0]) + " " + str(float(box[2])*100)# 画出检测到的目标物# self.names. box[0]image=self.drawRectBox(image,box[1],addText=label,color=self.colors[box[3]])# self.label_score_result.setText(str(len(self.detInfo) - count))# 在Qt界面中显示检测完成画面self.display_image(image)# self.label_display.display_image(image)defchoose_folder(self):self.timer_camera.stop()self.timer_video.stop()self.c_video=0ifself.capandself.cap.isOpened():self.cap.release()ifself.cap_video:self.cap_video.release()# 释放视频画面帧self.comboBox_select.clear()# 下拉选框的显示self.comboBox_select.addItem('所有目标')# 清除下拉选框self.clearUI()# 清除UI上的label显示self.flag_timer=""# 选择文件夹dir_choose=QFileDialog.getExistingDirectory(self.centralwidget,"选取文件夹",self.path)self.path=dir_choose# 保存路径ifdir_choose!="":self.textEdit_pic.setText(dir_choose+'文件夹已选中')self.label_display.setText('正在启动识别系统...\n\nleading')QtWidgets.QApplication.processEvents()rootdir=os.path.join(self.path)for(dirpath,dirnames,filenames)inos.walk(rootdir):forfilenameinfilenames:temp_type=os.path.splitext(filename)[1]iftemp_type=='.png'ortemp_type=='.jpg'ortemp_type=='.jpeg':img_path=dirpath+'/'+filename image=self.cv_imread(img_path)# 读取选择的图片image=cv2.resize(image,(850,500))img0=image.copy()img=letterbox(img0,new_shape=self.imgsz)[0]img=np.stack(img,0)img=img[:,:,::-1].transpose(2,0,1)# BGR to RGB, to 3x416x416img=np.ascontiguousarray(img)img=torch.from_numpy(img).to(self.device)# 把图像矩阵移至到训练单元中(GPU中或CPU中)img=img.half()ifself.halfelseimg.float()# 如果是半精度则转换图像格式img/=255.0# 归一化ifimg.ndimension()==3:# 如果图像时三维的添加1维变成4维img=img.unsqueeze(0)t1=time_synchronized()# 推理开始时间pred=self.model(img,augment=False)[0]# 前向推理pred=non_max_suppression(pred,self.opt.conf_thres,self.opt.iou_thres,classes=self.opt.classes,agnostic=self.opt.agnostic_nms)# NMS过滤t2=time_synchronized()# 结束时间det=pred[0]p,s,im0=None,'',img0 self.current_image=img0.copy()# save_path = str(Path(self.opt.save_dir) / Path(p).name) # 文件保存路径ifdetisnotNoneandlen(det):# 如果有检测信息则进入# self.label_numer_result.setText(str(len(det))) # 将检测个数放置到主界面中det[:,:4]=scale_coords(img.shape[2:],det[:,:4],im0.shape).round()# 把图像缩放至im0的尺寸number_i=0# 类别预编号self.detInfo=[]count=[0foriinself.count_name]for*xyxy,conf,clsinreversed(det):# 遍历检测信息c1,c2=(int(xyxy[0]),int(xyxy[1])),(int(xyxy[2]),int(xyxy[3]))# 将检测信息添加到字典中self.detInfo.append([self.names[int(cls)],[c1[0],c1[1],c2[0],c2[1]],'%.2f'%conf,int(cls)])number_i+=1# 编号数+1self.label_class_result.setText(str(self.names[int(cls)]))forcninrange(len(self.count_name)):ifself.names[int(cls)]==self.count_name[cn]:count[cn]+=1self.label_score_result.setText('%.2f'%conf)label='%s %.0f%%'%(self.names[int(cls)],conf*100)# 画出检测到的目标物# print(xyxy)im0=self.drawRectBox(im0,xyxy,alpha=0.2,addText=label,color=self.colors[int(cls)])self.label_xmin_result.setText(str(c1[0]))self.label_ymin_result.setText(str(c1[1]))self.label_xmax_result.setText(str(c2[0]))self.label_ymax_result.setText(str(c2[1]))# 将结果记录至列表中res_all=[self.names[int(cls)],conf.item(),[c1[0],c1[1],c2[0],c2[1]]]self.res_set.append(res_all)self.change_table(img_path,res_all[0],res_all[2],res_all[1])for_inrange(len(det)):self.count_table.append(count)# 记录各个类别数目# self.plotBar(self.count_name, count, self.colors, margin=30)self.label_numer_result.setText(str(sum(count)))# self.label_score_result.setText(str(len(det) - count))# 更新下拉选框self.comboBox_select.currentIndexChanged.disconnect(self.select_obj)self.comboBox_select.clear()self.comboBox_select.addItem('所有目标')foriinrange(len(self.detInfo)):text="{}-{}".format(self.detInfo[i][0],i+1)self.comboBox_select.addItem(text)self.comboBox_select.currentIndexChanged.connect(self.select_obj)image=im0.copy()InferenceNms=t2-t1# 单张图片推理时间self.label_time_result.setText(str(round(InferenceNms,2)))# 将推理时间放到右上角else:# 清除UI上的label显示self.label_numer_result.setText("0")self.label_class_result.setText('0')# font = QtGui.QFont()# font.setPointSize(16)# self.label_class_result.setFont(font)self.label_score_result.setText("0")# 显示置信度值# 清除位置坐标self.label_xmin_result.setText("0")self.label_ymin_result.setText("0")self.label_xmax_result.setText("0")self.label_ymax_result.setText("0")# 在Qt界面中显示检测完成画面self.detected_image=image.copy()self.display_image(image)# 在界面中显示画面QtWidgets.QApplication.processEvents()# self.label_display.display_image(image)else:self.clearUI()

5、源码获取方式

🍅由于篇幅限制,获取完整文章或源码、代做项目的,查看【用户名】、【专栏名称】就可以找到我啦🍅

感兴趣的可以先收藏起来,点赞、关注不迷路,下方查看👇🏻获取联系方式👇🏻

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询