title: read .yml files in matlab
body: <p>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 answers. </p>
  
  <p>My .yml files look like this </p>
  
  <pre><code>YAML:1.0
  Image file: "00032009.jpg"
  Contours count: 8
  Contours:
     -
        Name: FO
        Count: 41
        Closed: 0
        Points:
           -
              x: 682.5947265625000000
              y: 743.1998901367187500
           -
              x: 685.9638061523437500
              y: 771.3800659179687500
  </code></pre>
  
  <p>......</p>
  
  <p>and so on</p>
  
  <p>Note 00032009.jpg  is an image of a face
       x and y are coordinates of a point on a face Eg: the right corner of an eye etc</p>
  
  <p>Could you please point out a way to read the file and then display the points on the face image?</p>
  
  <p><strong>Edit 1:</strong> Here is the error I get</p>
  
  <pre><code>Error: File: ReadYamlRaw.m Line: 14 Column: 11
  Expression or statement is incorrect--possibly unbalanced (, {, or [.
  Error in ==&gt; ReadYaml at 38
      ry = ReadYamlRaw(filename, 0, nosuchfileaction);
  </code></pre>
  
  <p>What is weird is line 14 in ReadYamlRaw.m</p>
  
  <pre><code>[pth,~,~]= fileparts(mfilename('fullpath'));
  
   Parse error at ','(second one) and ']' usage appears to be invalid matlab syntax.
  </code></pre>
  
  <p>So what is the use of ~ in there and why is there an error?   </p>
  
  <p><strong>Edit2</strong>: I replaced the ~ in the line above with dummy variables then I get this errors O_O</p>
  
  <pre><code> Error using ==&gt; ReadYamlRaw&gt;scan at 81
  Unknown data type: logical
  
  Error in ==&gt; ReadYamlRaw&gt;scan_map at 138
              result.(ich) = scan(r.get(java.lang.String(ich)));
  
  Error in ==&gt; ReadYamlRaw&gt;scan at 79
          result = scan_map(r);
  
  Error in ==&gt; ReadYamlRaw&gt;scan_list at 116
          result{ii} = scan(i);
  
  Error in ==&gt; ReadYamlRaw&gt;scan at 77
          result = scan_list(r);
  
  Error in ==&gt; ReadYamlRaw&gt;scan_map at 138
              result.(ich) = scan(r.get(java.lang.String(ich)));
  
  Error in ==&gt; ReadYamlRaw&gt;scan at 79
          result = scan_map(r);
  
  Error in ==&gt; ReadYamlRaw&gt;load_yaml at 48
          result = scan(yaml.load(fileread([filename, fileext])));
  
  Error in ==&gt; ReadYamlRaw at 19
      result = load_yaml(filename, nosuchfileaction);
  
  Error in ==&gt; ReadYaml at 38
      ry = ReadYamlRaw(filename, 0, nosuchfileaction);
  </code></pre>
  
  <p>I also tried with a different yml file that looks like this</p>
  
  <pre><code>%YAML:1.0
  RE-C:
     x: 919
     y: 580
  LE-C:
     x: 1209
     y: 597
  N-C:
     x: 1063
     y: 698
  FO-B:
     x: 1045
     y: 1114
  REL-O:
     x: 852
     y: 597
  REL-I:
     x: 986
     y: 600
  REL-T:
     x: 918
     y: 564
  </code></pre>
  
  <p>And I get the following errors</p>
  
  <pre><code>Java exception occurred:
  while scanning a directive
   in "&lt;string&gt;", line 1, column 1:
      %YAML:1.0
      ^
  expected alphabetic or numeric character, but found :(58)
   in "&lt;string&gt;", line 1, column 6:
      %YAML:1.0
           ^
  
  
      at org.yaml.snakeyaml.scanner.ScannerImpl.scanDirectiveName(ScannerImpl.java:1028)
  
      at org.yaml.snakeyaml.scanner.ScannerImpl.scanDirective(ScannerImpl.java:990)
  
      at org.yaml.snakeyaml.scanner.ScannerImpl.fetchDirective(ScannerImpl.java:534)
  
      at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:251)
  
      at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:179)
  
      at
      org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(ParserImpl.java:198)
  
      at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:161)
  
      at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:146)
  
      at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105)
  
      at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:121)
  
      at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:480)
  
      at org.yaml.snakeyaml.Yaml.load(Yaml.java:399)
  
  
  Error in ==&gt; ReadYamlRaw&gt;load_yaml at 48
          result = scan(yaml.load(fileread([filename, fileext])));
  
  Error in ==&gt; ReadYamlRaw at 19
      result = load_yaml(filename, nosuchfileaction);
  
  Error in ==&gt; ReadYaml at 38
      ry = ReadYamlRaw(filename, 0, nosuchfileaction);
  </code></pre>
  
  <p>Maybe someone can make something out of these or you could point out another set of functions that would work? I searched but didn't find any except this one. </p>