a = [1 2 3 4]
b = [50 42 56 84]
c= polyfit( a, b,1 ) %matlab
result c = [ 11.6 29.0 ]
Is there any opencv code on this ?
Thanks in advancestrong text
a = [1 2 3 4]
b = [50 42 56 84]
c= polyfit( a, b,1 ) %matlab
result c = [ 11.6 29.0 ]
Is there any opencv code on this ?
Thanks in advancestrong text
Hi,
I don’t know such function in opencv.
You can use this code :
void polyfit(Mat x, Mat y, OutputArray z)
{
Mat xx = Mat::ones(x.rows, 2, CV_64F);
x.copyTo(xx(Range(0,x.rows),Range(0,1)));
SVD s(xx);
cout << xx << endl;
s.backSubst(y, z);
}
void main(void)
{
Mat x = (Mat_<double>(4, 1) << 1, 2, 3, 4);
Mat y = (Mat_<double>(4, 1) << 50, 42, 56, 84);
Mat z;
polyfit(x, y, z);
cout << z;
}