Hi! My apologies if my question format is not ideal, it's my first post here. I am trying to replace the following C++ code to python. Below are the codes and my attempt to debug. I will refer to the shape of matrix Row x Column as (M,N).
Input: iMeanXYMat, which is a (1000,2) matrix
For C++:
cvSVD(iMeanXYMat, pSigma1Mat, U, pCoefficientMat, CV_SVD_V_T);
cvMatMul(U, pSigma1Mat, pSigma1MatResult1);
cvMatMul( pSigma1MatResult1 ,pCoefficientMat, pSigma1MatTransposeCoeff);
Desired Output: pSigma1MatTransposeCoeff, (1000,2) matrix
For Python:
pSigma1Mat, U, pCoefficientMat = cv2.SVDecomp(iMeanXYMat)
pSigma1MatResult1= np.matmul(U, pSigma1Mat)
pSigma1MatTransposeCoeff= np.matmul( pSigma1MatResult1 ,pCoefficientMat)
Error Output: ValueError: shapes (1000,1) and (2,2) not aligned: 1 (dim 1) != 2 (dim 0)
What I have tried:
I realized that the shape of pSigma1Mat has to be (2,2). Since for python, pSigma1Mat output is (2,1), making pSigma1MatResult1 a (1000,1), leading to an error when pSigma1MatResult1 a (1000,1) multiply with pCoefficientMat a (2,2).
C++ allows `pSigma1Mat` to be output as (2,2) or NxN. However, there seems to be no such solution for python. I tried the code below but it's not working too.
pSigma1Mat, U, pCoefficientMat = cv2.SVDecomp(iMeanXYMat, flags = cv.SVD_FULL_UV)
Any help will be greatly appreciated, I will keep looking around and update if I find any solution. Thanks!