LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Least square method to fit y=f(y,x0,x1,x2,x3,a0,a1,...,a6) ?

I would like to perform a fit by using a least square method.
My fonction is something like that :

y=a0*f0+a1*f1+a2*f2+a3*f3+a4*f4+a5*f5+a6*f6

with :
f0=x0*x1
f1=x0*x3
f2=x0*x3
f3=x0
f4=-y*x1
f5=-y*x2
f6=-y*x3
I tried the linear fit .vi but although I don't get any error messages the results does not seem correct.
(I attached the files I made to create the H matrix and use the .vi.)

Could someone explain me how to do this fit ?

Thanks,

Juliane
Download All
0 Kudos
Message 1 of 6
(3,372 Views)


@Juliane wrote:
y=a0*f0+a1*f1+a2*f2+a3*f3+a4*f4+a5*f5+a6*f6

with :
f0=x0*x1
f1=x0*x3
f2=x0*x3
f3=x0
f4=-y*x1
f5=-y*x2
f6=-y*x3

Juliane,

Your function does not make sense, because y is also a function of y. Mathematically, f4 reduces to x1. Could it be your data is in two dimensions?

Can you put real data in your controls, make the current values default, save and repost your VI? Thanks! 🙂

0 Kudos
Message 2 of 6
(3,363 Views)
I'm back at home now so I'll send real data tomorrow morning. But, yes my function is 2D :

If I use the name of the data I used in my vi, it is in fact :
cXpd = a1*cYpd*wXw + a2*cYpd *wYw + a3*cYpd*wZw + a4*cYpd - a5*wXw - a6*wYw - a7*wZw
where
[wXw, wYw, wZw] are the 3D coordinates of a point
[cXpd, cYpd] the coordinates of a 2D point (which is the image of the above 3D point)

In my first post, I changed the name of the variables to make it simple to read:
y=cXpd
x0=cYpd
x1=wXw
x2=wYw
x3=wZw
So really, Y should be [cXpd, cYpd] and X should be [wXw, wYw, wZw] but then I don't see how I can find the A coefficients...

Regards,

Juliane
0 Kudos
Message 3 of 6
(3,356 Views)
Hello ,

I put in atachments the vi with the real data in the controls.

Regards,

Download All
0 Kudos
Message 4 of 6
(3,331 Views)

So really, Y should be [cXpd, cYpd] and X should be [wXw, wYw, wZw] but then I don't see how I can find the A coefficients...

OK, none of this make any sense at all. If it *should* be the above, why do you seemingly randomly do something else? 😉

You seem to randomly mix independent and dependent variables. Can we start from scratch and you just tell us a little bit about the experiment. How does the data look in 3D?

0 Kudos
Message 5 of 6
(3,322 Views)
Ok I'll try to explain a little bit :

I'm doing a camera calibration by using a method called the Tsaï method.
The final objective is to get a relationship between real world 3D points and their corresponding 2D image points.
My program is very big in fact as  there is a part that give me from the picture, the 2D coordinates (in pixel) of n image points. On another hand, I measure the coordinates of the n corresponding 3D points in the real world. I can explain you the Tsaï method but is quite long (it deals with projection, translation, rotation and scale factor...) and I don't think it is useful here.

The thing is that there is a step is this method where Tsaï say that we could use a least square method (he mentionned this method in particular) to determine from the two sets of data we have (i.e. [cXpd, cYpd] and the corresponding [wXw, wYw, wZw]) the A coefficients in the following equation (that the physics gave us):
cXpd=a1*cYpd*wXw+a2*cYpd*wYw+a3*cYpd*wZw+a4*cYpd-a5*cXpd*wXw-a6*cXpd*wYw-a7*cXpd*wZw

As I have n points of calibration, I should be able to write this equation n times and find the 7 A coefficients.

I thought I could use the LS linear fit vi to find them... but you're telling me I'm wrong, aren't you Smiley Sad?
Is there another vi I can use to do least square ?

0 Kudos
Message 6 of 6
(3,314 Views)