批量转换KITTI数据集到VOC的方法
1.Emacs法
2.Matlab法
-----------------------------------------------------------------------------------------------------------------------------------------------------------
1.Emacs法
http://www.cnblogs.com/linkboy1980/p/6527394.html
内容需要更改
改schema为
(setq etxml-KITTI-dataset-schema
"(\"object\"
(\"name\" @0@)
(\"pose\" 0)
(\"truncated\" (round-with-threshold (string-to-number @1@ ) 0.07) )
(\"difficult\" 0)
(\"bndbox\"
(\"xmin\" (round(string-to-number @4@)))
(\"ymin\" (round(string-to-number @5@)))
(\"xmax\" (round(string-to-number @6@)))
(\"ymax\" (round(string-to-number @7@)))
)
)"
)
改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。