Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::Mat.forEach w/ index

AFAIK the signature of the function param of Mat.forEach is:

void (*)(const T value, const *int pos);

Now, I'm not sure what the pos argument is and I don't think the documentation is absolutely clear on that. From the documentation, it looks like this is the channel of the current element?

Is there any way to get the current row/column/index in that function? I basically want to identify certain values and get that value plus an index, so that I know where in the Matrix I can find it.

cv::Mat.forEach w/ index- how does position work?

AFAIK the signature of the function param of Mat.forEach is:

void (*)(const T value, const *int pos);

EDIT: Well, according to core/utility.hpp it's more like: (which should go into the documentation, IMHO)

//     (_Tp&, const int*)   <- multidimential
//  or (_Tp&, void*)        <- in case of you don't need current idx.

Now, I'm not sure what the pos argument is and I don't think the documentation is absolutely clear on that. From the documentation, it almost looks like this is the channel of the current element?

Is there any way to get I have now used it in my project for a CV_64FC1 Matrix and pos[1] is the current row/column/index in that function? I basically collumn. Since pos[0] is always zero and this is a single row Matrix, I guess it's pos[dimension]?

So when I want to identify certain values and get that value plus an index, so that I know where in the Matrix I can find it. use it with m.at<t>() I need to calculate the index from the pos elments? I would like to better understand this, then I could make a pull request with a documentation improvement. I have looked at the code, but I'm not sure I understand the multidimensional case correctly.