testSVD.cpp
1 | #include <opencv2/imgproc/imgproc.hpp> |
---|---|
2 | #include <opencv2/highgui/highgui.hpp> |
3 | #include <opencv2/core/core.hpp> |
4 | #include <opencv2/features2d/features2d.hpp> |
5 | #include <opencv2/nonfree/nonfree.hpp> |
6 | #include "ros/ros.h" //ROS HEADER |
7 | |
8 | using namespace cv; |
9 | using namespace std; |
10 | int main (void){ |
11 | |
12 | Mat Dp(3,3,CV_32FC1); |
13 | Mat Dc(3,3,CV_32FC1); |
14 | Mat Q(3,3,CV_32FC1); |
15 | Mat U,Vt,R,T,W; |
16 | |
17 | Dp.at<float>(0,0)=0.86483884; Dp.at<float>(0,1)= -0.3077251; Dp.at<float>(0,2)=-0.55711365; |
18 | Dp.at<float>(1,0)=0.49294353; Dp.at<float>(1,1)=-0.24209651; Dp.at<float>(1,2)=-0.25084701; |
19 | Dp.at<float>(2,0)=0; Dp.at<float>(2,1)=0; Dp.at<float>(2,2)=0; |
20 | |
21 | Dc.at<float>(0,0)=0.75632739; Dc.at<float>(0,1)= -0.38859656; Dc.at<float>(0,2)=-0.36773083; |
22 | Dc.at<float>(1,0)=0.9699229; Dc.at<float>(1,1)=-0.49858192; Dc.at<float>(1,2)=-0.47134098; |
23 | Dc.at<float>(2,0)=0.10566688; Dc.at<float>(2,1)=-0.060333252; Dc.at<float>(2,2)=-0.045333147; |
24 | |
25 | Q=Dp*Dc.t(); |
26 | SVD decomp; |
27 | decomp=SVD(Q); |
28 | U=decomp.u; |
29 | Vt=decomp.vt; |
30 | W=decomp.w; |
31 | |
32 | R=Vt.t()*U.t(); |
33 | cout << "Dp=" << endl << Dp << endl;
|
34 | cout << "Dc=" << endl << Dc << endl;
|
35 | cout << "Q=" << endl << Q << endl;
|
36 | cout << "U=" << endl << U << endl;
|
37 | cout << "W=" << endl << W << endl;
|
38 | cout << "Vt=" << endl << Vt << endl;
|
39 | |
40 | return(0); |
41 | |
42 | }; |