| 84 | } |
| 85 | |
| 86 | cv::Mat phaseCorrelation(cv::Mat& x1, cv::Mat& x2, int h, int w, int channel) { |
| 87 | cv::Mat xy = cv::Mat(h, w, CV_32FC2, cv::Scalar(0)); |
| 88 | cv::Mat xy_temp; |
| 89 | cv::Mat x; |
| 90 | cv::Mat y; |
| 91 | cv::Mat d; |
| 92 | cv::Mat d2; |
| 93 | for (int i = 0; i < channel; i++) { |
| 94 | x = x1.row(i).reshape(1, h);; |
| 95 | y = x2.row(i).reshape(1, h); |
| 96 | cv::mulSpectrums(fftd(x), fftd(y), xy_temp, 0, true); |
| 97 | cv::mulSpectrums(xy_temp, xy_temp, d, 0, true); |
| 98 | cv::sqrt(real(d), d); |
| 99 | d += 2.2204e-16; |
| 100 | //d = complexDivision(xy_temp, d); |
| 101 | std::vector<cv::Mat> planes = { d,d }; |
| 102 | cv::merge(planes, d2); |
| 103 | cv::divide(xy_temp, d2, xy_temp); |
| 104 | //xy_temp = complexDivision(xy_temp, d2); |
| 105 | xy_temp.convertTo(xy_temp, CV_32F); |
| 106 | xy += xy_temp; |
| 107 | } |
| 108 | return xy; |
| 109 | } |
no test coverage detected