CoreLibrary does have a C++ based dataset to read from and write to CVML based .xml files, however, they are still not .mat file as MATLAB users expected.
The first step, please use emacs or any editor you would prefer to copy and paste the following code in a file called: 'cvml_csv.xslt'.
<?
xml
version
=
"1.0"
?>
<
xsl:output
method
=
"text"
/>
<
xsl:variable
name
=
"sep"
select
=
"' '"
/>
<
xsl:template
match
=
"/"
>
<
xsl:for-each
select
=
"dataset/frame"
>
<
xsl:for-each
select
=
"objectlist/object"
>
<
xsl:value-of
select
=
"../../@number"
/>
<
xsl:copy-of
select
=
"$sep"
/>
<
xsl:value-of
select
=
"@id"
/>
<
xsl:copy-of
select
=
"$sep"
/>
<
xsl:value-of
select
=
"box/@xc"
/>
<
xsl:copy-of
select
=
"$sep"
/>
<
xsl:value-of
select
=
"box/@yc"
/>
<
xsl:copy-of
select
=
"$sep"
/>
<
xsl:value-of
select
=
"box/@w"
/>
<
xsl:copy-of
select
=
"$sep"
/>
<
xsl:value-of
select
=
"box/@h"
/>
<
xsl:value-of
select
=
"'
'"
/>
</
xsl:for-each
>
</
xsl:for-each
>
</
xsl:template
>
</
xsl:stylesheet
>
2nd step: Let us assume, you CVML .xml file is called: fwbs1gt.xml. Then type in the following command in your terminal
xsltproc cvml_csv.xslt fwbs1gt.xml > fwbs1gt.csv
3rd step: read csv file into matlab, by typing the following command in MATLAB command windows.
A = dlmread('fwbs1gt.csv');
4th step: For A, there will be n rows 6 columns. The 1st columns is the frame number. 2nd is the object id within the frame. 3rd to 6th column is the bounding box information.
Again, this blog is mainly for a record to myself. If you have confusion, please go to blog: http://www.gnebehay.com/?p=5. The author has done a great work to introduce this whole topic.
All credit goes to that author.
No comments:
Post a Comment