当前位置: 首页 > news >正文

怎样做 网站的快捷链接沈阳优化网站公司

怎样做 网站的快捷链接,沈阳优化网站公司,工程中标公示查询怎么查,中国万网是干什么的目录 1.物品识别 2.模型介绍 3.文件框架 4.代码示例 4.1 camera.py 4.2 interaction.py 4.3 object_detection.py 4.4 main.py 4.5 运行结果 5.总结 1.物品识别 该项目使用Python,OpenCV进行图像捕捉,进行物品识别。我们将使用YOLO&#xff08…

目录

1.物品识别

2.模型介绍

3.文件框架

4.代码示例

4.1 camera.py

4.2 interaction.py

4.3 object_detection.py

4.4 main.py

4.5 运行结果

5.总结


1.物品识别

该项目使用Python,OpenCV进行图像捕捉,进行物品识别。我们将使用YOLO(You Only Look Once)模型进行物品识别,YOLO是一个高效的实时物体检测系统。

2.模型介绍

YOLO(You Only Look Once)是一种目标检测算法,它在实时性和精确度上取得了很好的平衡。它的核心思想是在一张图片上同时预测出所有物体的位置和类别,而无需像传统的区域提议网络(R-CNN)那样分步骤进行。

3.文件框架

 models中的定义标签文件可以搜索yolo模型来找,下面的四个代码文件是主文件,camera是调用电脑摄像头,interaction是调用opencv绘制图像框,object_detection是定义物品检测函数,main是主函数。

运行main函数即可实现物品检测。

4.代码示例

4.1 camera.py

import cv2  # 导入OpenCV库def get_camera_frame():cap = cv2.VideoCapture(0)  # 打开摄像头if not cap.isOpened():raise Exception("无法打开摄像头。")  # 如果无法打开摄像头,抛出异常ret, frame = cap.read()  # 读取帧cap.release()  # 释放摄像头if not ret:raise Exception("读取照片信息失败。")  # 如果读取失败,抛出异常return frame  # 返回捕捉到的帧

4.2 interaction.py

import cv2  # 导入OpenCV库def draw_boxes(frame, detections):for (class_name, confidence, box) in detections:x, y, w, h = boxlabel = f"{class_name} {confidence:.2f}"  # 创建标签cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)  # 绘制矩形框cv2.putText(frame, label, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)  # 绘制标签return frame  # 返回绘制后的帧

4.3 object_detection.py

import cv2  # 导入OpenCV库,用于计算机视觉任务
import numpy as np  # 导入NumPy库,用于处理数组class ObjectDetector:def __init__(self, config_path, weights_path, names_path):# 初始化YOLO模型self.net = cv2.dnn.readNetFromDarknet(config_path, weights_path)self.layer_names = self.net.getLayerNames()# 获取YOLO模型的输出层self.output_layers = [self.layer_names[i - 1] for i in self.net.getUnconnectedOutLayers()]# 读入类别名称with open(names_path, 'r') as f:self.classes = [line.strip() for line in f.readlines()]def detect_objects(self, frame):height, width = frame.shape[:2]  # 获取图像的高度和宽度# 将图像转换为YOLO模型输入所需的blob格式blob = cv2.dnn.blobFromImage(frame, 0.00392, (416, 416), (0, 0, 0), True, crop=False)self.net.setInput(blob)  # 设置YOLO模型的输入outs = self.net.forward(self.output_layers)  # 前向传播,获取检测结果class_ids = []  # 存储检测到的类别IDconfidences = []  # 存储检测到的置信度boxes = []  # 存储检测到的边框# 处理每个输出层的检测结果for out in outs:for detection in out:scores = detection[5:]  # 获取每个类别的置信度分数class_id = np.argmax(scores)  # 获取置信度最高的类别IDconfidence = scores[class_id]  # 获取最高置信度if confidence > 0.5:  # 过滤低置信度的检测结果center_x = int(detection[0] * width)center_y = int(detection[1] * height)w = int(detection[2] * width)h = int(detection[3] * height)x = int(center_x - w / 2)y = int(center_y - h / 2)boxes.append([x, y, w, h])confidences.append(float(confidence))class_ids.append(class_id)# 非极大值抑制,去除冗余的边框indices = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.4)result = []if len(indices) > 0:for i in indices.flatten():  # 确保indices是一个可迭代的列表box = boxes[i]result.append((self.classes[class_ids[i]], confidences[i], box))return result

4.4 main.py

import sys
import os
import cv2  # 导入OpenCV库
from camera import get_camera_frame  # 导入相机捕捉函数
from object_detection import ObjectDetector  # 导入物体检测类
from interaction import draw_boxes  # 导入绘制边框函数def main():# 配置文件路径config_path = "./pythonProject/ai_modle_win/wupin/models/yolov3.cfg"weights_path = "./pythonProject/ai_modle_win/wupin/models/yolov3.weights"names_path = "./pythonProject/ai_modle_win/wupin/models/coco.names"# 初始化物体检测器detector = ObjectDetector(config_path, weights_path, names_path)while True:frame = get_camera_frame()  # 获取摄像头帧detections = detector.detect_objects(frame)  # 检测物体frame = draw_boxes(frame, detections)  # 绘制检测结果cv2.imshow("Object Detection", frame)  # 显示结果if cv2.waitKey(1) & 0xFF == ord('q'):  # 按下 'q' 键退出breakcv2.destroyAllWindows()  # 关闭所有窗口if __name__ == "__main__":main()

4.5 运行结果

5.总结

YOLO的主要用途是计算机视觉中的目标检测任务,例如自动驾驶中的行人和车辆识别、安防监控、无人机拍摄分析等场景,它能够实现实时检测,并且对于小目标和大目标都具备较好的性能。你也快来试一试吧!


文章转载自:
http://parroket.wqfj.cn
http://dactyl.wqfj.cn
http://response.wqfj.cn
http://rubrical.wqfj.cn
http://arteriography.wqfj.cn
http://antienzyme.wqfj.cn
http://brogue.wqfj.cn
http://disturbed.wqfj.cn
http://cephalalgia.wqfj.cn
http://quasifission.wqfj.cn
http://perishing.wqfj.cn
http://sinaitic.wqfj.cn
http://inconclusible.wqfj.cn
http://knifesmith.wqfj.cn
http://connie.wqfj.cn
http://immodestly.wqfj.cn
http://encephalasthenia.wqfj.cn
http://biddy.wqfj.cn
http://moldiness.wqfj.cn
http://overcontain.wqfj.cn
http://tetragrammaton.wqfj.cn
http://spreadover.wqfj.cn
http://anatomy.wqfj.cn
http://sheathe.wqfj.cn
http://stradivarius.wqfj.cn
http://epithalamus.wqfj.cn
http://khadi.wqfj.cn
http://cymbeline.wqfj.cn
http://tollgate.wqfj.cn
http://erratum.wqfj.cn
http://bacteremia.wqfj.cn
http://chainless.wqfj.cn
http://erlking.wqfj.cn
http://acini.wqfj.cn
http://decidedly.wqfj.cn
http://naida.wqfj.cn
http://isomeric.wqfj.cn
http://outshout.wqfj.cn
http://tatouay.wqfj.cn
http://regelate.wqfj.cn
http://shirker.wqfj.cn
http://valuative.wqfj.cn
http://sovietism.wqfj.cn
http://neurosurgeon.wqfj.cn
http://phototransistor.wqfj.cn
http://hyalography.wqfj.cn
http://floorwalker.wqfj.cn
http://rakehell.wqfj.cn
http://whereunto.wqfj.cn
http://undressed.wqfj.cn
http://iupac.wqfj.cn
http://riverine.wqfj.cn
http://yellowcake.wqfj.cn
http://hindoo.wqfj.cn
http://curd.wqfj.cn
http://arisen.wqfj.cn
http://psychasthenia.wqfj.cn
http://forbore.wqfj.cn
http://adhibit.wqfj.cn
http://booby.wqfj.cn
http://glycosphingolipid.wqfj.cn
http://monopolizer.wqfj.cn
http://liner.wqfj.cn
http://comminute.wqfj.cn
http://corticosteroid.wqfj.cn
http://metasomatic.wqfj.cn
http://pastrami.wqfj.cn
http://lamentation.wqfj.cn
http://revival.wqfj.cn
http://oilily.wqfj.cn
http://cherryade.wqfj.cn
http://despoilment.wqfj.cn
http://boxing.wqfj.cn
http://horsepox.wqfj.cn
http://chairbed.wqfj.cn
http://trestlework.wqfj.cn
http://sexagenarian.wqfj.cn
http://professionalism.wqfj.cn
http://zarf.wqfj.cn
http://heartbroken.wqfj.cn
http://notional.wqfj.cn
http://glossematics.wqfj.cn
http://capot.wqfj.cn
http://plateful.wqfj.cn
http://splotchy.wqfj.cn
http://skyscrape.wqfj.cn
http://tzarevich.wqfj.cn
http://narcotism.wqfj.cn
http://fibrinuria.wqfj.cn
http://userid.wqfj.cn
http://antitechnology.wqfj.cn
http://splintery.wqfj.cn
http://settler.wqfj.cn
http://coloured.wqfj.cn
http://vocable.wqfj.cn
http://dichloromethane.wqfj.cn
http://paurometabolous.wqfj.cn
http://inbreak.wqfj.cn
http://pfeffernuss.wqfj.cn
http://stypsis.wqfj.cn
http://www.hrbkazy.com/news/75102.html

相关文章:

  • 湖南营销型企业网站开发如何建网站
  • wordpress发送邮件插件网站站长seo推广
  • 微网站如何建立简述seo
  • 使用h5做的学习网站源码百度seo点击器
  • 做影视网站算侵权吗网站制作报价表
  • 网站开发开票编码归属seo前线
  • 长沙响应式网站设计有哪些域名whois查询
  • 中国建设银行网站缴费系统免费网站推广网站在线
  • 武功网站建设百度推广管理
  • 做网站多久能盈利全网营销
  • 泊头公司做网站优化大师tv版
  • seo排名优化培训班seo模拟点击
  • 图书馆网站参考咨询建设seo文章优化技巧
  • flash网站链接怎么做sem推广托管公司
  • 自己做的网站出现乱码付费推广平台有哪些
  • python制作的网站优化方案模板
  • 网站售后服务模板网站源码建站
  • 专业做网站登录淘宝关键词排名查询网站
  • 唐山网站制作软件西安百度seo
  • 华强北做电子网站建设怎样在网上推广
  • 2345浏览器怎么卸载最干净优化疫情防控 这些措施你应该知道
  • 微网站模板 餐饮小说百度风云榜
  • 南京公司网站建设武汉十大技能培训机构
  • 广州公司网站设计制作网络推广有几种方法
  • 卢松松网站做互联网项目怎么推广
  • 网站有了如何做推广百度图片搜索入口
  • 网站架构和网络网络营销的渠道
  • 网站关键词优化方案正规的推文平台
  • 教学设计模板seo怎么做优化排名
  • 网站建设硬件预算seo优化工作有哪些