freakTheMighty
freakTheMighty

Reputation: 1181

least square solution to camera matrix [numpy]

I would like to use use numpy's least square algorithm to solve for a camera matrix from 6 known 3D -> 2D point correspondence.

I have been using this website as a reference:

http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/OWENS/LECT9/node4.html

Currently my camera matrix seems to have very small values:

[[ -1.01534118e-11   3.87508914e-11  -2.75515236e-11   5.57599976e+02]
 [ -1.84008233e-11   2.78083388e-11  -9.67788509e-11   9.77599976e+02]
 [ -2.59237076e-14  -8.57647287e-15  -9.09272657e-14   1.00000000e+00]]

I would like to be able to constrain the numpy solver to prevent it from solving for the trivial solution where the Camera matrix is nearly zero.
Does anyone know how to constrain numpy.linalg.lstsqr()?

Upvotes: 0

Views: 1448

Answers (3)

denis
denis

Reputation: 21947

Would least squares staying near a point x0 be of any use, i.e. is there a camera matrix x0 you want to be near to ?
"Keep away from some x0" is non-convex, nasty; keep near x0 or x1 ..., i.e. minimize
|Ax-b|^2 + w^2 (|x-x0|^2 + |x-x1|^2 + ...) is easy.

Upvotes: 0

Foofy
Foofy

Reputation: 208

I need to get scipy installed properly

Just a note for installing scipy, ubuntu distributions since 8.04 have had a broken scipy build. That has been taken care of in the latest 9.10 beta build. You could build scipy from scratch, but it isn't in general an easy thing to do. Just a heads up because it took some effort for us here to get that figured out. Maybe it'll save you some frustration =)

Upvotes: 1

Rupert Nash
Rupert Nash

Reputation: 1554

I suspect you may need to use the fmin_* routines in scipy.optimize. The optimization tutorial covers basic use and scipy.optimize.fmin_slsqp can include constraints.

Upvotes: 1

Related Questions