嵌入式学习-土堆目标检测(1)-day26

发布于:2025-07-22 ⋅ 阅读:(19) ⋅ 点赞:(0)

土堆pytorch已经学完了,目前开始学目标检测,一些数据集的使用,然后目标检测的基本结构,再是yolo模型,再是ultralytics框架

土堆官网,一些教程,工具, 膜拜大佬 ORZ: 我是土堆 | 我是土堆

目标检测,就是我们希望计算机在图像或者视频定位识别我们感兴趣的目标

识别:识别矩阵框中的内容

感兴趣的目标,不仅可以是一些常规的目标,也可以是一些“非常规”或者说是抽象的目标

定位:在图像中找到目标的位置,用矩阵框表示出来

这就是目标检测

常见的目标检测数据集 

数据集可以在这里下载: Machine Learning Datasets | Papers With Code

数据集涉及到 输入 和 输出 所以比较重要

VOC数据集

VOC数据集:VOC数据集官网  ,2012和2007最为常用

VOC2012下载网址:http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar

VOC2007下载网址:http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar

JPEGImages是图片文件

annotations是标注

其他的不用关心

annotations标注文件例子及关键说明:

<annotation>
	<folder>VOC2007</folder>
	<filename>000019.jpg</filename>
	<source>
		<database>The VOC2007 Database</database>
		<annotation>PASCAL VOC2007</annotation>
		<image>flickr</image>
		<flickrid>330638158</flickrid>
	</source>
	<owner>
		<flickrid>Rosenberg1/ Simmo</flickrid>
		<name>?</name>
	</owner>
	<size>                        //图像大小
		<width>500</width>  
		<height>375</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
	<object>
		<name>cat</name>            //目标种类
		<pose>Right</pose>
		<truncated>0</truncated>    //是否被遮挡
		<difficult>0</difficult>    //识别难度
		<bndbox>
			<xmin>231</xmin>
			<ymin>88</ymin>
			<xmax>483</xmax>
			<ymax>256</ymax>
		</bndbox>
	</object>
	<object>
		<name>cat</name>
		<pose>Right</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>11</xmin>
			<ymin>113</ymin>
			<xmax>266</xmax>
			<ymax>259</ymax>
		</bndbox>
	</object>
</annotation>

图片查看软件ImageJ下载:Download

COCO数据集 

更大比VOC更常用

网址: COCO - Common Objects in Context

下载2017文件夹解压缩后就这三个,train2017和val2017就是图片

 注意instances就可以了,存储的是目标检测标注

 可以用tudui的COCO查看工具

 图片信息:重点关注下面这三个

 标注信息:重要的

如果我们想找到0000391895jpg的所有标注,那么我们需要找到标注信息中image_id=391895的所有标注。相当于是主键

Bbox中的数字分别代表(xmin,ymin,width,height) 

category_id可以从categories中找到目标是什么物体

类别ID是4,确实是摩托车

 

YOLO标注格式

现在比较常用,也是介绍的最后一个格式

x_yolo = x / image_width        y_yolo = y / height

width_yolo = width / image_width         height_yolo = height / image_height

yolo format bounding box  = <x_yolo, y_yolo, width_yolo, height_yolo>

用这张照片举例子

看到他图片的width = 500 height = 333

物体的中心点的坐标是 x = 250 y = 184 w = 196 h = 172

则:

x_yolo = x / image_width =  0.5     y_yolo = y / height = 0.55

width_yolo = width / image_width   =  0.392      height_yolo = height / image_height = 0.516

yolo format bounding box  = <x_yolo, y_yolo, width_yolo, height_yolo>  = <0.51,0.55,0.392,0.516>

 用土堆的网页检测看到是对的


网站公告

今日签到

点亮在社区的每一天
去签到