Reputation: 752
I am trying to get the row and col of a particular element from a CvMat which is a 3-channel matrix.
Is there any function in OpenCV with which I can get this? Something like Matlab's 'find' function, maybe?
Upvotes: 0
Views: 329
Reputation: 12514
If that "particular element" is a color pixel and it is unique, you can mask it using
inRange(src,your_color,your_color,mask)
then use minMaxLoc()
to get the index of that unique point you are looking for.
Of course this is only worth it if you are not after a single pixel (get the single pixel rather with a simple loop), but if you don't do too many of this it could be easier to do this overkill, as it is short, afterall.
If you are looking for a submatrix, use matchTemplate
then minMaxLoc
to get the index.
Upvotes: 1
Reputation: 1358
I never heard about such function in Opencv. still you can scan your matrix looking for the value you need to find. I think also "find" function works in a similar way.
Upvotes: 0