Ask Your Question

Eran's profile - activity

2014-03-06 14:23:23 -0600 received badge  Organizer (source)
2014-03-06 14:16:36 -0600 asked a question I'm having trouble reading YAML

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!

2014-02-04 02:53:50 -0600 commented question BFMatcher crosscheck

When I run your code at first I've got this error: error: ‘struct cv::DMatch’ has no member named ‘empty’ but then I've noticed you wrote that you use std::vector<std::vector<dmatch>> matches

So from what you wrote here, you have a set of matches that you check only the first match!! (match[i][0]) that why you never go deep to the knn garbage I've solved it by looking at the distance as I wrote in my answer.

2014-02-04 02:52:25 -0600 answered a question BFMatcher crosscheck

I've came across with thus issue also. I tried to avoid it but I was needed that cross-check. You can see the matches results:

BFMatcher matcher(NORM_L2):
-- Max dist : 1.656894 
-- Min dist : 0.855967 
0. distance: 0.906053, imgIdx: 0, queryIdx: 0, trainIdx: 14
1. distance: 1.11377, imgIdx: 0, queryIdx: 1, trainIdx: 20
2. distance: 0.998074, imgIdx: 0, queryIdx: 2, trainIdx: 14
3. distance: 1.65689, imgIdx: 0, queryIdx: 3, trainIdx: 5
4. distance: 1.04289, imgIdx: 0, queryIdx: 4, trainIdx: 14
5. distance: 1.45203, imgIdx: 0, queryIdx: 5, trainIdx: 6
6. distance: 1.60162, imgIdx: 0, queryIdx: 6, trainIdx: 6
7. distance: 0.968847, imgIdx: 0, queryIdx: 7, trainIdx: 56
8. distance: 0.900678, imgIdx: 0, queryIdx: 8, trainIdx: 56
9. distance: 0.855967, imgIdx: 0, queryIdx: 9, trainIdx: 88
10. distance: 1.29085, imgIdx: 0, queryIdx: 10, trainIdx: 88
11. distance: 1.49221, imgIdx: 0, queryIdx: 11, trainIdx: 43
12. distance: 1.2633, imgIdx: 0, queryIdx: 12, trainIdx: 103
13. distance: 1.36239, imgIdx: 0, queryIdx: 13, trainIdx: 43
14. distance: 1.54558, imgIdx: 0, queryIdx: 14, trainIdx: 88
15. distance: 0.980541, imgIdx: 0, queryIdx: 15, trainIdx: 103

BFMatcher matcher(NORM_L2,1):
-- Max dist : 0.775846 
-- Min dist : 0.000000 
0. distance: 0.191887, imgIdx: 0, queryIdx: 0, trainIdx: 14
1. distance: 0.236683, imgIdx: 0, queryIdx: 1, trainIdx: 20
2. distance: 0.775846, imgIdx: 0, queryIdx: 2, trainIdx: 150
3. distance: 0.58364, imgIdx: 0, queryIdx: 3, trainIdx: 119
4. distance: 0.54844, imgIdx: 0, queryIdx: 4, trainIdx: 137
5. distance: 0.375308, imgIdx: 0, queryIdx: 5, trainIdx: 44
6. distance: 0.292175, imgIdx: 0, queryIdx: 6, trainIdx: 6
7. distance: 0.33761, imgIdx: 0, queryIdx: 7, trainIdx: 40
8. distance: 0.217681, imgIdx: 0, queryIdx: 8, trainIdx: 56
9. distance: 0.173051, imgIdx: 0, queryIdx: 9, trainIdx: 88
10. distance: 0.317514, imgIdx: 0, queryIdx: 10, trainIdx: 97
11. distance: 0.526101, imgIdx: 0, queryIdx: 12, trainIdx: 107
12. distance: 0.394886, imgIdx: 0, queryIdx: 13, trainIdx: 43
13. distance: 0.444844, imgIdx: 0, queryIdx: 14, trainIdx: 17
14. distance: 0.210094, imgIdx: 0, queryIdx: 15, trainIdx: 103
15. distance: 1.96182e-44, imgIdx: 0, queryIdx: 1063263759, trainIdx: 265

(which give me the next error when it try to draw matches: OpenCV Error: Assertion failed (i1 >= 0 && i1 < static_cast<int>(keypoints1.size())) in drawMatches, file /home/eran/opencv-2.4.6.1/modules/features2d/src/draw.cpp, line 207)

I've solved it by removing it from my good_matches

  • imgIdx - sometimes wrong sometimes ok
  • queryIdx & trainIdx - most of times garbaged only in one side
  • distance - always somwething very small. in this case: 1.96182e-44

I added this code to min-max loop and the good_matches loop:

if (matches[i].distance < 0.00001) continue;

I hope that this number 0.00001 will catch all cases.

Or someone will fix this knn match bug :~