I would like to read .yml files in Matlab. These files contain coordinates x and y of key points on a face image. I looked for different tools but I don\'t seem to find any
ZozaniDB Database Toolbox comes with a Matlab-native YAML implementation that handles the .yml file here. To parse a string or a file, use:
>> yaml_parse ( str )
>> yaml_read ( filename )
It's YAML file indeed (as @DavidBrown mentioned in his comment, the extension does not matter). But it has some problems. Don't know if it's due to wrong YAML format or MATLAB implementation.
I've installed YAMLMATLAB and played a little with your file.
YamlStruct = ReadYaml(yaml_file);
YAMLMATLAB returns error if the files is feed as is. It works only if I comment the first line and remove spaces from field names. So the beginning of the file looks like this:
#YAML:1.0
Imagefile: 00032009.jpg
Contourscount: 8
...skipped the rest...
Then I get the correct structure. For example you can access the 1st point's x
coordinate as
YamlStruct.Contours{1}.Points{1}.x
ans =
682.5947
UPDATE
Space in filed names is actually a known problem in YAMLMATLAB. See the report and possible solution here.
UPDATE 2
According to comment from @Jirka_cigler (YAMLMATLAB developers group):
In the program release 0.4.3 we added support for whitespaces in field names, so the problem should not appear again.
Great!
I've also removed previous developers comment on the problem in the first UPDATE since it's not true any more.