I am trying to convert the following c++ line into OpenCV matrix operation (which is also c++):
double myCode::calculate ( int i, int au )
{
double k;
for ( int j = 0; i < N; i ++ );
{
k += fabs(data[i][j] - means[au][j]);
}
}
I want to define “data” and “means” as openCV matrix type, like:
cv::Mat data ( NUMBER_OF_OBSERVATIONS, N, CV_8UC3 );
cv::Mat means = cv::Mat.zeros ( 5, N, CV_8UC3 );
then repeat the above class for this cvMat type “data” and “means”. How can I do that? Especially I don’t know how to do the line:
k += fabs(data[i][j] - means[au][j]);
Thanks a lot.
You can simply write
Note that
RowRange()is not actually the correct syntax – look in OpenCV docs for the proper usage ofRange(), but that’s the idea.