python之json文件轉xml文件案例講解_第1頁
python之json文件轉xml文件案例講解_第2頁
python之json文件轉xml文件案例講解_第3頁
python之json文件轉xml文件案例講解_第4頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

第python之json文件轉xml文件案例講解這是yolov4模型跑出來的檢測結果result.json

下面是截取的一張圖的檢測結果

"frame_id":1,#圖片的序號

"filename":"/media/wuzhou/Gap/rgb-piglet/test/00000000.jpg",#圖片的路徑

"objects":[#該圖中所有的目標:目標類別、目標名稱、歸一化的框的坐標(xywh格式)、置信度

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.750913,"center_y":0.402691,"width":0.038380,"height":0.193304},"confidence":0.995435},

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.764775,"center_y":0.199255,"width":0.049979,"height":0.130169},"confidence":0.994495},

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.560050,"center_y":0.482614,"width":0.036331,"height":0.166377},"confidence":0.994460},

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.710756,"center_y":0.406446,"width":0.041782,"height":0.191297},"confidence":0.993540},

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.638335,"center_y":0.238725,"width":0.107689,"height":0.092282},"confidence":0.992926},

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.780232,"center_y":0.448454,"width":0.041550,"height":0.179540},"confidence":0.990020},

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.563412,"center_y":0.350035,"width":0.103184,"height":0.059460},"confidence":0.979756},

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.522591,"center_y":0.195170,"width":0.083014,"height":0.071478},"confidence":0.970642},

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.658721,"center_y":0.154640,"width":0.103852,"height":0.055686},"confidence":0.967082},

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.537660,"center_y":0.256810,"width":0.101619,"height":0.095211},"confidence":0.918135},

{"class_id":0,"name":"pp","relative_coordinates":{"center_x":0.528618,"center_y":0.481005,"width":0.033226,"height":0.177723},"confidence":0.310291}

代碼需要指定圖片的路徑,例如file_dir="H:/rgb-piglet/five/test"

注意:result.json文件要跟圖片放一起

代碼生成的xml與圖片在同一個路徑下

importjson

importtime

importos

fromPILimportImage

importcv2

importnumpyasnp

'''人為構造xml文件的格式'''

out0='''annotation

folder%(folder)s/folder

filename%(name)s/filename

path%(path)s/path

source

databaseNone/database

/source

size

width%(width)d/width

height%(height)d/height

depth3/depth

/size

segmented0/segmented

out1='''object

name%(class)s/name

poseUnspecified/pose

truncated0/truncated

difficult0/difficult

bndbox

xmin%(xmin)d/xmin

ymin%(ymin)d/ymin

xmax%(xmax)d/xmax

ymax%(ymax)d/ymax

/bndbox

/object

out2='''/annotation

defread_jso

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論