Reputation: 6842
Given opencv::Mat m1,m2
, I want to check if m1[i][j]
and m2[i][j]
are equal.
I've seen that there are two ways to do this:
if(m1.row(i).col(j) == m2.row(i).col(j))
and:
if(m1.at<float>(i,j)==m2.at<float>(i,j))
Notice that both m1
and m2
are SIFT matrix descriptors (so float
is the element type).
My question is: what's the difference between the two access methods?
Upvotes: 1
Views: 557
Reputation: 726839
Although the net result of the two operations is the same, the first one is more costly:
m1.row(i)
creates a Mat
object representing row i
, thencol(j)
is called on the Mat
returned from m1.row(i)
to get a single-element Mat
representing object at (i, j)
m2
Mat
objects are compared with ==
In contrast, m1.at<float>(i,j)
simply returns a float
, which then gets compared to the other float, without creating any additional objects.
Upvotes: 2