這是一個(gè)手機(jī)目標(biāo)檢測(cè)的數(shù)據(jù)集,數(shù)據(jù)集的標(biāo)注工具是labelimg,數(shù)據(jù)格式是voc格式,要訓(xùn)練yolo模型的話,可以使用腳本改成txt格式,數(shù)據(jù)集標(biāo)注了手機(jī),標(biāo)簽名:telephone,數(shù)據(jù)集總共有1960張,有一部分是直實(shí)數(shù)據(jù),有一部分是是真實(shí)數(shù)據(jù)。
數(shù)據(jù)集地址:https://download.csdn.net/download/matt45m/89136478
數(shù)據(jù)標(biāo)注如下:
數(shù)據(jù)保存目錄如下:
xml標(biāo)簽文件:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-852042.html
<annotation>
<folder>JPEGImages</folder>
<filename>bs001783.jpg</filename>
<path>JPEGImages\bs001783.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>1920</width>
<height>1080</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>telephone</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1058</xmin>
<ymin>936</ymin>
<xmax>1123</xmax>
<ymax>977</ymax>
</bndbox>
</object>
</annotation>
python代碼實(shí)現(xiàn)可視化:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-852042.html
import xml.etree.ElementTree as ET
import os
import cv2
# ******************************************
src_XML_dir = r'labels' # xml源路徑
src_IMG_dir = r'images' # IMG原路徑
IMG_format = '.jpg' # IMG格式
out_dir = 'out' # 輸出路徑
# ******************************************
if not os.path.exists(out_dir):
os.makedirs(out_dir)
xml_file = os.listdir(src_XML_dir) # 只返回文件名稱,帶后綴
for each_XML in xml_file: # 遍歷所有xml文件
# 讀入IMG
xml_FirstName = os.path.splitext(each_XML)[0]
img_save_file = os.path.join(out_dir, xml_FirstName+IMG_format)
img_src_path = os.path.join(src_IMG_dir, xml_FirstName+IMG_format)
img = cv2.imread(img_src_path)
# 解析XML
each_XML_fullPath = src_XML_dir + '/' + each_XML # 每個(gè)xml文件的完整路徑
tree = ET.parse(each_XML_fullPath) # ET.parse()內(nèi)要為完整相對(duì)路徑
root = tree.getroot() # 類型為element
# 畫(huà)框
for obj in root.findall('object'):
if obj.find('bndbox'):
bndbox = obj.find('bndbox')
xmin = int(bndbox.find('xmin').text)
xmax = int(bndbox.find('xmax').text)
ymin = int(bndbox.find('ymin').text)
ymax = int(bndbox.find('ymax').text)
cv2.rectangle(img=img,
pt1=(xmin,ymin),
pt2=(xmax,ymax),
color=(255,0,0),
thickness=2)
cv2.imwrite(filename=img_save_file, img=img)
print('保存結(jié)果{}'.format(xml_FirstName))
到了這里,關(guān)于計(jì)算機(jī)視覺(jué)——手機(jī)目標(biāo)檢測(cè)數(shù)據(jù)集的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!