00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef _LINEAR_ALGEBRA_CV_H_
00038 #define _LINEAR_ALGEBRA_CV_H_
00039
00040 #include "opencv/cv.h"
00041
00042
00043
00044
00045 class CFloatMatrix;
00046 class CFloatVector;
00047 class CDoubleMatrix;
00048 class CDoubleVector;
00049 struct Mat3d;
00050 struct Vec2d;
00051
00052
00053
00054
00055
00056
00057
00062 namespace LinearAlgebraCV
00063 {
00064
00065
00066
00067 void SVD(const CFloatMatrix *A, CFloatMatrix *W, CFloatMatrix *U = 0, CFloatMatrix *V = 0,
00068 bool bAllowModifyA = false, bool bReturnUTransposed = false, bool bReturnVTransposed = false);
00069
00070
00071 void SolveLinearLeastSquaresSimple(const CFloatMatrix *A, const CFloatVector *b, CFloatVector *x);
00072 void SolveLinearLeastSquaresSVD(const CFloatMatrix *A, const CFloatVector *b, CFloatVector *x);
00073 void SolveLinearLeastSquaresHomogeneousSVD(const CFloatMatrix *A, CFloatVector *x);
00074
00075
00076 void CalculatePseudoInverseSVD(const CFloatMatrix *pInputMatrix, CFloatMatrix *pOutputMatrix);
00077 void CalculatePseudoInverseSimple(const CFloatMatrix *pInputMatrix, CFloatMatrix *pResultMatrix);
00078
00079
00080 void Multiply(const CFloatMatrix *A, const CFloatMatrix *B, CFloatMatrix *pResultMatrix, bool bTransposeB = false);
00081 void Invert(const CFloatMatrix *A, const CFloatMatrix *pResultMatrix);
00082 void Transpose(const CFloatMatrix *A, const CFloatMatrix *pResultMatrix);
00083 void SelfProduct(const CFloatMatrix *pMatrix, CFloatMatrix *pResultMatrix, bool bTransposeSecond = false);
00084
00085
00086 bool DetermineAffineTransformation(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD = false);
00087 bool DetermineHomography(const Vec2d *pSourcePoints, const Vec2d *pTargetPoints, int nPoints, Mat3d &A, bool bUseSVD = false);
00088
00089
00090 void CalculateCovarianceMatrix(const CFloatMatrix *pMatrix, CFloatMatrix *pCovarianceMatrix);
00091
00092
00093 void PCA(const CFloatMatrix *pData, CFloatMatrix *pTransformationMatrix, CFloatMatrix *pTransformedData, int nTargetDimension);
00094 void PCA(const CFloatMatrix *pData, CFloatMatrix *pTransformationMatrix, CFloatMatrix *pEigenValues);
00095
00096
00097
00098
00099
00100
00101 void SVD(const CDoubleMatrix *A, CDoubleMatrix *W, CDoubleMatrix *U = 0, CDoubleMatrix *V = 0,
00102 bool bAllowModifyA = false, bool bReturnUTransposed = false, bool bReturnVTransposed = false);
00103
00104
00105 void SolveLinearLeastSquaresSimple(const CDoubleMatrix *A, const CDoubleVector *b, CDoubleVector *x);
00106 void SolveLinearLeastSquaresSVD(const CDoubleMatrix *A, const CDoubleVector *b, CDoubleVector *x);
00107 void SolveLinearLeastSquaresHomogeneousSVD(const CDoubleMatrix *A, CDoubleVector *x);
00108
00109
00110 void CalculatePseudoInverseSVD(const CDoubleMatrix *pInputMatrix, CDoubleMatrix *pOutputMatrix);
00111 void CalculatePseudoInverseSimple(const CDoubleMatrix *pInputMatrix, CDoubleMatrix *pResultMatrix);
00112
00113
00114 void Multiply(const CDoubleMatrix *A, const CDoubleMatrix *B, CDoubleMatrix *pResultMatrix, bool bTransposeB = false);
00115 void Invert(const CDoubleMatrix *A, const CDoubleMatrix *pResultMatrix);
00116 void Transpose(const CDoubleMatrix *A, const CDoubleMatrix *pResultMatrix);
00117 }
00118
00119
00120
00121 #endif