I'm having trouble reading YAML

asked 2014-03-06 14:16:36 -0600

Eran gravatar image

updated 2014-03-06 14:23:44 -0600

I have this YAML file that I've built

items.yml:

%YAML:1.0
#items:
-
  item   : 1
  round  : true
  hc     : [50,110,40,270,330]
  detect : 
  area   : 0
-
  item   : 2
  round  : true
  hc     : [50,110,40,270,330]
  detect : SURF
  area   : 0
-
  item   : 3
  round  : false
  hc     : null
  detect : SURF
  area   : 2
...

I also have Item struct that fits to the items YAML I want to add them to vector<item> in a loop. I have read the yaml spec, and opencv docs and examples I've tried a lot to read the YAML file but every time a came across with annoying exceptions.

1. The struct it self is very sensitive more than some online YAML editors that I tried them on (tabs and whitespace), so this is how I got to this, a working non errors FileStorage, construction of the YAML file. If I need to change it please fix me.

2. The reading is somehow more complex. I've read before only yaml object:value with no loop needed But here I'm not sure how to loop this. I've saw YAML libraries solutions that get size and the main object but I failed doing it myself.

Any help would be appreciated. thanks!

edit retag flag offensive close merge delete

Comments

your yaml file does not look acceptible for opencv. filestorage is a key-value store, you're lacking unique keys ("_" is no replacement for that). also you can't have null or empy values and again, what is SURF ? i't not a string .

berak gravatar imageberak ( 2014-03-07 03:14:57 -0600 )edit