| 33 | |
| 34 | template<typename T> |
| 35 | void fill_dst(const std::vector<T> &srcVec, const std::vector<T> &modelsVec, std::vector<T> &dstVec, std::size_t numSamples) |
| 36 | { |
| 37 | for (std::size_t i = 0; i < numSamples; i++) |
| 38 | { |
| 39 | const T* model = &modelsVec[i * 9]; |
| 40 | std::size_t numPoints = srcVec.size() / (2 * numSamples); |
| 41 | for (std::size_t j = 0; j < numPoints; j++) |
| 42 | { |
| 43 | T x = srcVec[i * numPoints * 2 + j * 2]; |
| 44 | T y = srcVec[i * numPoints * 2 + j * 2 + 1]; |
| 45 | |
| 46 | // Apply homography transformation: |
| 47 | T w = model[6] * x + model[7] * y + model[8]; |
| 48 | |
| 49 | if (std::abs(w) > 1e-10) { |
| 50 | w = 1.0 / w; |
| 51 | T x_transformed = (model[0] * x + model[1] * y + model[2]) * w; |
| 52 | T y_transformed = (model[3] * x + model[4] * y + model[5]) * w; |
| 53 | |
| 54 | dstVec[i * numPoints * 2 + j * 2] = x_transformed; |
| 55 | dstVec[i * numPoints * 2 + j * 2 + 1] = y_transformed; |
| 56 | } else { |
| 57 | dstVec[i * numPoints * 2 + j * 2] = 0; |
| 58 | dstVec[i * numPoints * 2 + j * 2 + 1] = 0; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | template<typename T> |
| 65 | void fill_tensor(nvcv::Tensor &tensor, const std::vector<T> &vec) |
no test coverage detected