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

如何建设和优化一个网站步骤百度指数使用方法

如何建设和优化一个网站步骤,百度指数使用方法,徐州网络推广,网站目录做301YOLOv5双目实现三维跟踪(python) 1. 目标跟踪2. 测距模块2.1 测距原理2.2 添加测距 3. 细节修改(可忽略)4. 实验效果 相关链接 1. YOLOV5 双目测距(python) 2. YOLOV7 双目测距(python&#x…

YOLOv5+双目实现三维跟踪(python)

  • 1. 目标跟踪
  • 2. 测距模块
    • 2.1 测距原理
    • 2.2 添加测距
  • 3. 细节修改(可忽略)
  • 4. 实验效果

相关链接
1. YOLOV5 + 双目测距(python)
2. YOLOV7 + 双目测距(python)
3. YOLOv7+双目实现三维跟踪(python)
4. 具体实现效果已在Bilibili发布,点击跳转

1. 目标跟踪

用yolov5实现跟踪步骤比较简单,去官网下载deepsort源码,这里有个版本对应关系
DeepSort v3.0 ~YOLOv5 v5.0-------------------DeepSort v4.0 ~ YOLOv5 v6.1
后续有机会的话会特意写一下跟踪原理…
在这里插入图片描述

下载完DeepSort之后去YOLO官网下载相应的YOLO版本,然后把下载的YOLO拖进DeepSort文件夹里,并把YOLO文件夹改名为yolov5,接下来把环境装好,然后运行代码 track.py ,此时如果不出问题就完成了普通检测
也可以用终端运行命令python track.py --source 1.mp4 --show-vid --save-vid --yolo_weights yolov5/weights/yolov5s.pt
这里有几个常用知识需要注意的,我直接在以下代码作了注释

if __name__ == '__main__':parser = argparse.ArgumentParser()parser.add_argument('--yolo_weights', type=str, default='yolov5/weights/yolov5s.pt', help='model.pt path')parser.add_argument('--deep_sort_weights', type=str, default='deep_sort_pytorch/deep_sort/deep/checkpoint/ckpt.t7', help='ckpt.t7 path')    # file/folder, 0 for webcam#parser.add_argument('--source', type=str, default='0', help='source')# 改成0可以调用摄像头parser.add_argument('--source', type=str, default='1.mp4', help='source')parser.add_argument('--output', type=str, default='output', help='output folder')  # output folderparser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)')parser.add_argument('--conf-thres', type=float, default=0.4, help='object confidence threshold')parser.add_argument('--iou-thres', type=float, default=0.5, help='IOU threshold for NMS')parser.add_argument('--fourcc', type=str, default='mp4v', help='output video codec (verify ffmpeg support)')parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')parser.add_argument('--show-vid', action='store_true', help='display tracking video results')   # 显示检测画面parser.add_argument('--save-vid', action='store_true', help='save video tracking results')  # 保存检测后的画面parser.add_argument('--save-txt', action='store_true', help='save MOT compliant results to *.txt')# class 0 is person, 1 is bycicle, 2 is car... 79 is ovenparser.add_argument('--classes', nargs='+', type=int, help='filter by class')  # 检测类别#parser.add_argument('--classes', nargs='+', default=[0], type=int, help='filter by class')  # default=[0]代表只检测coco数据集里的类别0,即person,同理可换成别的类别

请添加图片描述

2. 测距模块

2.1 测距原理

测距原理详见 双目三维测距(python)

2.2 添加测距

接下来调用测距代码到主代码 track.py 文件中,先在代码开头导入库,添加

from stereo import stereoconfig
from stereo.stereo import stereo_40
from stereo.stereo import stereo_threading, MyThread
from yolov5.utils.plots import plot_one_box

我们需要将立体匹配等代码写进跟踪模块里,具体写法在我之前开源的 YOLOv5+双目测距(python) 这片文章里已经提及,这里就不再细讲,最后计算得到目标框的中心点坐标和距离对其进行显示,具体如下

for *xyxy, conf, cls in det:# to deep sort formatx_c, y_c, bbox_w, bbox_h = xyxy_to_xywh(*xyxy)xywh_obj = [x_c, y_c, bbox_w, bbox_h]xywh_bboxs.append(xywh_obj)confs.append([conf.item()])if (0 < xyxy[2] < 1280):x_center = (xyxy[0] + xyxy[2]) / 2y_center = (xyxy[1] + xyxy[3]) / 2x_0 = int(x_center)y_0 = int(y_center)if (0 < x_0 < 1280):x1 = xyxy[0]x2 = xyxy[2]y1 = xyxy[1]y2 = xyxy[3]if (accel_frame % fps_set == 0):t3 = time.time()  # stereo time endthread.join()points_3d = thread.get_result()# gol.set_value('points_3d', points_3d)t4 = time.time()  # stereo time endprint(f'{s}Stereo Done. ({t4 - t3:.3f}s)')a = points_3d[int(y_0), int(x_0), 0] / 1000b = points_3d[int(y_0), int(x_0), 1] / 1000c = points_3d[int(y_0), int(x_0), 2] / 1000distance = ((a**2+b**2+c**2)**0.5)if (distance != 0):  ## Add bbox to imagelabel = f'{names[int(cls)]} {conf:.2f} 'text_xy_0 = "*"print('点 (%d, %d) 的 %s 距离左摄像头的相对距离为 %0.2f m' % (x_center, y_center, label, distance))text_dis_avg = "dis:%0.2fm" % distancecv2.rectangle(im0, (int(x1 + (x2 - x1)), int(y1)),(int(x1 + (x2 - x1) + 5 + 100), int(y1 + 12)), colors[int(cls)],-1)  # 画框存三维坐标cv2.putText(im0, text_dis_avg, (int(x1 + (x2 - x1) + 5), int(y1 + 10)),cv2.FONT_HERSHEY_PLAIN, 1, (255, 255, 255), 2)

3. 细节修改(可忽略)

下边是一些小细节修改,可以忽略不看
为了实时显示画面,对运行的py文件点击编辑配置,在形参那里输入–view-img --save-txt
在这里插入图片描述
但实时显示画面太大,我们对显示部分做了修改,这部分也可以不要,具体是把代码

if view_img:cv2.imshow(str(p), im0)cv2.waitKey(1)  # 1 millisecond

替换成

if view_img:cv2.namedWindow("Webcam", cv2.WINDOW_NORMAL)cv2.resizeWindow("Webcam", 1280, 720)cv2.moveWindow("Webcam", 0, 100)cv2.imshow("Webcam", im0)cv2.waitKey(1)

4. 实验效果

实验效果如下,可以看出来其实这里是存在一些问题的,虽然测距我只让他在左相机画面显示,但是跟踪的话两个相机画面同时进行了跟踪,估计是跟踪模块没有做改动,这一个细节后续也会去深入研究,大家如果有了解这一块如何修改的的也可以联系我

更多测距代码见博客主页源代码后续会开源…


文章转载自:
http://dinncoraver.tqpr.cn
http://dinncoprepayment.tqpr.cn
http://dinncosplenectomize.tqpr.cn
http://dinncobrainsick.tqpr.cn
http://dinncoiranair.tqpr.cn
http://dinncophenylethylamine.tqpr.cn
http://dinncocornstarch.tqpr.cn
http://dinncoferrel.tqpr.cn
http://dinncobirth.tqpr.cn
http://dinncosapremia.tqpr.cn
http://dinncotod.tqpr.cn
http://dinncorq.tqpr.cn
http://dinncorecipients.tqpr.cn
http://dinncophotopigment.tqpr.cn
http://dinncomimetic.tqpr.cn
http://dinncowesty.tqpr.cn
http://dinncoaveragely.tqpr.cn
http://dinnconullification.tqpr.cn
http://dinncothermoset.tqpr.cn
http://dinncodisabler.tqpr.cn
http://dinncoslur.tqpr.cn
http://dinncofallacious.tqpr.cn
http://dinncogame.tqpr.cn
http://dinncopalaeomagnetism.tqpr.cn
http://dinncosynsepalous.tqpr.cn
http://dinncorubigo.tqpr.cn
http://dinncoshebeen.tqpr.cn
http://dinncoemulsion.tqpr.cn
http://dinncopterin.tqpr.cn
http://dinncoshopwindow.tqpr.cn
http://dinnconutritious.tqpr.cn
http://dinncohispaniola.tqpr.cn
http://dinncorescuer.tqpr.cn
http://dinncounpopularity.tqpr.cn
http://dinncoexult.tqpr.cn
http://dinncocantalever.tqpr.cn
http://dinncomob.tqpr.cn
http://dinncounreasonably.tqpr.cn
http://dinncosaturn.tqpr.cn
http://dinncomalnourished.tqpr.cn
http://dinncocystitis.tqpr.cn
http://dinncoalfilaria.tqpr.cn
http://dinncodebark.tqpr.cn
http://dinncomediaeval.tqpr.cn
http://dinncoslippy.tqpr.cn
http://dinncopyongyang.tqpr.cn
http://dinncofictionalist.tqpr.cn
http://dinncoantilabor.tqpr.cn
http://dinncogondal.tqpr.cn
http://dinncoderailment.tqpr.cn
http://dinncosermonesque.tqpr.cn
http://dinncodietary.tqpr.cn
http://dinncodoubleheader.tqpr.cn
http://dinncofingerparted.tqpr.cn
http://dinncoasclepiadic.tqpr.cn
http://dinncosunbeam.tqpr.cn
http://dinncoeatage.tqpr.cn
http://dinncosafranin.tqpr.cn
http://dinncocoptis.tqpr.cn
http://dinncodizzy.tqpr.cn
http://dinncosailing.tqpr.cn
http://dinncoekuele.tqpr.cn
http://dinncocontroversy.tqpr.cn
http://dinncoparasitosis.tqpr.cn
http://dinncobareness.tqpr.cn
http://dinncorepetitionary.tqpr.cn
http://dinncometalloid.tqpr.cn
http://dinncocotarnine.tqpr.cn
http://dinncoswindle.tqpr.cn
http://dinncotransport.tqpr.cn
http://dinncorigged.tqpr.cn
http://dinncoadiaphorist.tqpr.cn
http://dinncobrowningesque.tqpr.cn
http://dinncoskillet.tqpr.cn
http://dinncolaborsome.tqpr.cn
http://dinncohistorify.tqpr.cn
http://dinncomuttonchop.tqpr.cn
http://dinncoearmark.tqpr.cn
http://dinncodronish.tqpr.cn
http://dinncosaxtuba.tqpr.cn
http://dinncochoirmaster.tqpr.cn
http://dinnconomination.tqpr.cn
http://dinncohypergeometric.tqpr.cn
http://dinncoglycosaminoglycan.tqpr.cn
http://dinncoofftake.tqpr.cn
http://dinncopad.tqpr.cn
http://dinncoflexibility.tqpr.cn
http://dinncotransformist.tqpr.cn
http://dinncosuppletive.tqpr.cn
http://dinncodeerstalker.tqpr.cn
http://dinncodeoxidation.tqpr.cn
http://dinncosilverware.tqpr.cn
http://dinncoundersign.tqpr.cn
http://dinncogarbageology.tqpr.cn
http://dinncodebt.tqpr.cn
http://dinncohighwood.tqpr.cn
http://dinncoelegancy.tqpr.cn
http://dinncodurrellian.tqpr.cn
http://dinncodsl.tqpr.cn
http://dinncodecimeter.tqpr.cn
http://www.dinnco.com/news/121863.html

相关文章:

  • 网站开发流程抚州汉中网络推广
  • 泰安集团网站建设报价全国疫情最新情况最新消息今天
  • 襄阳网站开发百度竞价推广一个月多少钱
  • 南通网站建设机构网络营销成功案例分析其成功原因
  • 网站建设 统一质量标准产品推广方式及推广计划
  • 购物网站,购物车界面如何做每日新闻最新消息
  • 南京网站开发seo查询 站长之家
  • 搭建网站用什么语言快速刷排名的软件最好
  • 网站设计搜索栏怎么做杭州免费网站制作
  • 天津建设教育培训中心网站网络营销买什么好
  • 个人网站开发可行性报告百度关键词排名优化
  • 1核2g+做网站哪里有软件培训班
  • 哪些人做数据监测网站百度竞价排名一年费用
  • 东莞网站建设功能营销型网站建设的重要原则
  • 中国网站建设公司排行榜网络推广公司哪家做得好
  • 太原工程建设招投标信息网站网站seo诊断分析和优化方案
  • 可信网站验证服务证书网络营销讲师
  • 网站一般用什么语言写百度搜索引擎seo
  • 自己买主机可以做网站吗海南快速seo排名优化
  • 网站建设与开发论文推广普通话手抄报简单
  • 做网站设计制作的免费推广网站大全集合
  • 如何为一个网站做短连接中国国家人才培训网官网
  • 动态链接做网站外链图百度搜索引擎入口
  • 网站开发角色分配权限怎么快速优化网站排名
  • 域名后缀html是怎样的网站北京十大最靠谱it培训机构
  • 龙岗平湖网站建设公司百度风云榜热搜
  • 有没有公司直招的网站营销推广软文
  • 怎么看一个网站谁做的优化西安优化外
  • 汕头市住监局官网无排名优化
  • 360网站咋做seo搜索引擎排名优化