| 33 | // Fix cv::getPerspectiveTransform for double |
| 34 | template<class T> |
| 35 | cv::Mat GetPerspectiveTransform(const std::vector<cv::Point_<T>>& src, const std::vector<cv::Point_<T>>& dst, int solveMethod) |
| 36 | { |
| 37 | cv::Mat M(3, 3, CV_64F), X(8, 1, CV_64F, M.ptr()); |
| 38 | double a[8][8], b[8]; |
| 39 | cv::Mat A(8, 8, CV_64F, a), B(8, 1, CV_64F, b); |
| 40 | |
| 41 | for (int i = 0; i < 4; ++i) |
| 42 | { |
| 43 | a[i][0] = a[i + 4][3] = src[i].x; |
| 44 | a[i][1] = a[i + 4][4] = src[i].y; |
| 45 | a[i][2] = a[i + 4][5] = 1; |
| 46 | a[i][3] = a[i][4] = a[i][5] = a[i + 4][0] = a[i + 4][1] = a[i + 4][2] = 0; |
| 47 | a[i][6] = -src[i].x * dst[i].x; |
| 48 | a[i][7] = -src[i].y * dst[i].x; |
| 49 | a[i + 4][6] = -src[i].x * dst[i].y; |
| 50 | a[i + 4][7] = -src[i].y * dst[i].y; |
| 51 | b[i] = dst[i].x; |
| 52 | b[i + 4] = dst[i].y; |
| 53 | } |
| 54 | |
| 55 | cv::solve(A, B, X, solveMethod); |
| 56 | M.ptr<double>()[8] = 1.; |
| 57 | |
| 58 | return M; |
| 59 | } |
| 60 | |
| 61 | /// |
| 62 | /// \brief The GeoParams class |
no test coverage detected