Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Mat operation

I have vector ay[4] , then I get the mean of vector. So, I change the vector to matrix. like this

Mat total,rata;
total =  Mat(ay[1]) + Mat(ay[2]) + Mat(ay[3]);
rata = total/3;
cout <<"Total"<< total << endl;
cout <<"Rata"<< rata << endl;

Then, I use the mean of matrix for get the deviation, this the code.

Mat dev[4], chg[4];
for (int abc=0; abc<4; abc++){
    chg[abc] = Mat(ay[abc]);
}
for(int s=0; s<4;s++){
    cv::subtract(chg[s],rata,dev[s]);
}
cout << "Data" << dev[1] << endl;

when, I operation this code. the program was break. and this is the error

OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array') in cv::arithm_op, file ........\opencv\modules\core\src\arithm.cpp, line 1287

I dont know why, but that are have the same initialization. Thanks.

Mat operation

I have vector ay[4] , then I get the mean of vector. So, I change the vector to matrix. like this

Mat total,rata;
total =  Mat(ay[1]) + Mat(ay[2]) + Mat(ay[3]);
rata = total/3;
cout <<"Total"<< total << endl;
cout <<"Rata"<< rata << endl;

Then, I use the mean of matrix for get the deviation, this is the code.

Mat dev[4], chg[4];
for (int abc=0; abc<4; abc++){
    chg[abc] = Mat(ay[abc]);
}
for(int s=0; s<4;s++){
    cv::subtract(chg[s],rata,dev[s]);
}
cout << "Data" << dev[1] << endl;

when, I operation this code. the program was break. and this is the error

OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array') in cv::arithm_op, file ........\opencv\modules\core\src\arithm.cpp, line 1287

I dont know why, but that are have the same initialization. Thanks.