I´m studing the code of OpenCV, and I came across the next few lines:
The function´s var are:
CvMat* _err;
CvMat* _mask;
int i, count = _err->rows*_err->cols, goodCount = 0;
for( i = 0; i < count; i++ )
goodCount += mask[i] = err[i] <= threshold; // This line is strange for me
return goodCount;
What does the line I indicated actually do? Because, call me strange, I have never seen anything like that.
For your information:
- Yes, the code is working 😀
- The code is part of the
CvModelEstimator2::findInliersfunction.
That line is evil.
Nevertheless, it assigns
1tomask[i]iferr[i] <= thresholdand0otherwise.Then it increments
goodCountif the condition holds.