MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / fill_dst

Function fill_dst

bench/BenchFindHomography.cpp:35–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34template<typename T>
35void 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
64template<typename T>
65void fill_tensor(nvcv::Tensor &tensor, const std::vector<T> &vec)

Callers 1

FindHomographyFunction · 0.85

Calls 2

absFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected