1 | initial version |
One way of avoiding/understanding these errors is printing out the type.
When you run print(type(matches))
you will see that bf.match(desL,desR)
returns a list. So accessing trainIdx
on the entire list makes no sense at all.
Instead, you want to find the trainIdx
of a particular match inside this list.For example, if you want to access the trainIdx of the first match, do matches[0]
.
The second problem in your code is trainIdx[:10]
. This means that trainIdx
returns a list and you are trying to access every element in it from index 0 to index 10. But if you again run print(type(matches[0].trainIdx))
, it will return an int
and not a list
.
So the correct syntax for accessing the training id of the first match should be print(matches[0].trainIdx)
.
I will let you figure out how to access the remaining training idxs of all the matches.
Whenever in doubt, refer to the documentation.
Cheers :)
2 | No.2 Revision |
One way of avoiding/understanding these errors is printing out the type.
When you run print(type(matches))
you will see that bf.match(desL,desR)
returns a list. So accessing trainIdx
on the entire list makes no sense at all.
Instead, you want to find the first extract a particular match inside this trainIdx
of list.For list. For example, if you want to access the trainIdx of the first first match, do matches[0]
.
The second problem in your code is trainIdx[:10]
. This means that trainIdx
returns a list and you are trying to access every element in it from index 0 to index 10. But if you again run print(type(matches[0].trainIdx))
, it will return an int
and not a list
.
So the correct syntax for accessing the training id of the first match should be print(matches[0].trainIdx)
.
I will let you figure out how to access the remaining training idxs of all the matches.
Whenever in doubt, refer to the documentation.
Cheers :)
3 | No.3 Revision |
One way of avoiding/understanding these errors is printing out the type.
When you run print(type(matches))
you will see that bf.match(desL,desR)
returns a list. So accessing trainIdx
on the entire list makes no sense at all.
Instead, you want to first extract a particular match inside this list. For example, if you want to access the first first match, do matches[0]
.
The second problem in your code is trainIdx[:10]
. This means that trainIdx
returns a list and you are trying to access every element in it from index 0 to index 10. But if you again run print(type(matches[0].trainIdx))
, it will return an int
and not a list
.
So the correct syntax for accessing the training id of the first match should be print(matches[0].trainIdx)
.
I will let you figure out how to access the remaining training idxs of all the matches.
Whenever in doubt, refer to the documentation.
Cheers :)