imglab使用:
imglab程式網盤地址:
鏈接:https://pan.baidu.com/s/1G2ui4TyM3pgJ3pjjH7ygSA
提取碼:70c7
獲取圖片串列:./XXX/imglab.exe(imglab位置) -c ./XXX/(檔案名).xml (圖片所在的檔案夾) (多個檔案夾......)
標注圖片:./XXX/imglab.exe(imglab位置) ./XXX/(檔案名).xml
注意:不會自動保存,不要忘了保存!!!
tips:
- 按住shift鍵、單擊滑鼠左鍵并拖動來添加一個新的矩形,在矩形右下角顯示,編輯好的標簽,
- 按住shift鍵,右鍵矩形邊框調整矩形
- 雙擊選中框,shift+左鍵標注特征點、shift+右鍵修改特征點
- 洗掉:選中框+del
- 縮放:ctrl+滑鼠滾軸
- 洗掉當前圖片:alt+del
- 當前圖片的標注順延至下一張圖片:shift +
讀取.xml檔案實體
.xml檔案部分:
例子的.xml檔案之含有框資訊,readxml檔案實作的是求框的中點,
#box top + left 左上角的點
<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet type='textl' href='image_metadata_stylesheet.xsl'?>
<dataset>
<name>imglab dataset</name>
<comment>Created by imglab tool.</comment>
<images>
<image file='left\P_20_-10_-10_6_L01.bmp'>
<box top='74' left='19' width='170' height='80'/>
</image>
<image file='left\P_20_-10_-15_6_L01.bmp'>
<box top='93' left='22' width='171' height='64'/>
</image>
<image file='left\P_20_-10_-20_6_L01.bmp'>
<box top='84' left='17' width='175' height='75'/>
</image>
<image file='left\P_20_-10_-25_6_L01.bmp'>
<box top='91' left='23' width='166' height='74'/>
readxml.py,保存資訊在mark.txt檔案中,
import xml.etree.ElementTree as ET # 讀取xml,
import os
from PIL import Image, ImageDraw, ImageFont
source_path = 'F:/DataDeal/mark'
savefilename = 'F:/DataDeal/' + 'mark.txt'
if __name__ == "__main__":
data = []
with open(savefilename, 'w') as write_file_handler:
for root, dirs, files in os.walk(source_path):
for file in files:
dirpath = 'F:/DataDeal/mark/' + file
tree = ET.parse(dirpath) # 決議讀取xml函式
id = file.split('_')[0]
root = tree.getroot()
for i in range(len(root[2])):
c_x = int(root[2][i][0].attrib['left']) + int(int(root[2][i][0].attrib['width'])/2)
c_y = int(root[2][i][0].attrib['top']) + int(int(root[2][i][0].attrib['height'])/2)
data.append(id + '\\' + root[2][i].attrib['file'] + ' ' + str(c_x) + ' ' + str(c_y))
data.append('\n')
write_file_handler.writelines(data)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/402575.html
標籤:其他
