39 float u2,
float v2,
float up2,
float vp2,
40 float u3,
float v3,
float up3,
float vp3,
41 float u4,
float v4,
float up4,
float vp4)
45 estimate(u1, v1, up1, vp1,
53 if (AA) cvReleaseMat(&AA);
54 if (B) cvReleaseMat(&AA);
55 if (X) cvReleaseMat(&AA);
56 if (AA_n) cvReleaseMat(&AA_n);
57 if (B_n) cvReleaseMat(&AA_n);
58 if (X_n) cvReleaseMat(&AA_n);
62 void homography::initialize(
void)
64 AA = cvCreateMat(8, 8, CV_32FC1);
65 B = cvCreateMat(8, 1, CV_32FC1);
66 X = cvCreateMat(8, 1, CV_32FC1);
72 actual_match_number = 0;
77 type = CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | CV_MAT_TYPE(type);
80 step = cols * CV_ELEM_SIZE(type);
81 data.ptr = (uchar*)
new float[cols * rows];
95 float u,
float v,
float up,
float vp)
97 int row = point_index * 2;
125 float u2,
float v2,
float up2,
float vp2,
126 float u3,
float v3,
float up3,
float vp3,
127 float u4,
float v4,
float up4,
float vp4)
129 add_match(AA, B, 0, u1, v1, up1, vp1);
130 add_match(AA, B, 1, u2, v2, up2, vp2);
131 add_match(AA, B, 2, u3, v3, up3, vp3);
132 add_match(AA, B, 3, u4, v4, up4, vp4);
134 int ok = cvSolve(AA, B, X, CV_SVD);
138 cerr <<
"homography::estimate: cvSolve failure" << endl;
180 actual_match_number = 0;
185 AA_n = cvCreateMat(2 * match_number, 8, CV_32FC1);
186 X_n = cvCreateMat(8, 1, CV_32FC1);
187 B_n = cvCreateMat(2 * match_number, 1, CV_32FC1);
199 add_match(AA_n, B_n, actual_match_number, u, v, up, vp);
200 actual_match_number++;
205 if (match_number != actual_match_number)
207 cerr <<
"error when calling estimate_linear_method: not enough given matches." << endl;
211 int ok = cvSolve(AA_n, B_n, X_n, CV_SVD);
215 cerr <<
"homography::estimate: cvSolve failure" << endl;