欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Emacs

程序员文章站 2024-03-18 14:14:40
...

批量转换KITTI数据集到VOC的方法

1.Emacs法

2.Matlab法

-----------------------------------------------------------------------------------------------------------------------------------------------------------

1.Emacs法

http://www.cnblogs.com/linkboy1980/p/6527394.html

内容需要更改

改schema为




(setq etxml-KITTI-dataset-schema 
"(\"object\" 
	(\"name\" @[email protected])
	(\"pose\" 0)
	(\"truncated\"  (round-with-threshold (string-to-number @[email protected] ) 0.07) ) 
	(\"difficult\" 0) 
	(\"bndbox\" 
		(\"xmin\" (round(string-to-number @[email protected]))) 
		(\"ymin\" (round(string-to-number @[email protected])))
 		(\"xmax\" (round(string-to-number @[email protected])))
 		(\"ymax\" (round(string-to-number @[email protected])))
	)  
)"
)




改defun etxml-KITTI-print-buffer-to-xml 为
(defun etxml-KITTI-print-buffer-to-xml ()
  (interactive) 
  (let* ((dest-buffer  (concat (buffer-name) ".xml") )
	 (original-buffer (buffer-name))
	 (original-file-name (file-name-sans-extension original-buffer ) )
	 (image-file-path (concat kitti-image-root original-file-name  ".png"))
	 (image-dims (image-size (create-image image-file-path) t) )
	 )
    (unless (bufferp dest-buffer)
      (setq dest-buffer (get-buffer-create  dest-buffer) ) )
    (with-current-buffer  dest-buffer
 	(insert (concat "<annotation>\n<folder>VOC2007</folder>\n"  ) )
 	(insert (concat "<filename>" original-file-name  ".png</filename>\n"))
	(insert (concat "<source>\n<database>The VOC2007 Database</database>\n<annotation>VOC2007</annotation>\n<image>flickr</image>\n<flickrid>NULL</flickrid>\n</source>\n"))
 	(insert (concat "<owner>\n<flickrid>YU Xiaochuan</flickrid>\n<name>YU Xiaochuan</name>\n</owner>"))
 	(insert (concat "<size>\n<width>" (number-to-string (car image-dims)) "</width>\n<height>" (number-to-string  (cdr image-dims)) "</height>\n<depth>3</depth>\n</size>\n" ))
	(insert (concat "<segmented>0</segmented>\n"))
      )
    (etxml-print-buffer-to-xml etxml-KITTI-dataset-schema nil dest-buffer )
    (with-current-buffer dest-buffer
      (insert "</annotation>")
      )
    )
  )



可以得到与VOC2007完全匹配的xml标注文件。
Emacs细节:
一年成为Emacs高手
2.Github RRC方法中的MATLAB脚本
https://github.com/xiaohaoChen/rrc_detection。