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

Function FindHomography

bench/BenchFindHomography.cpp:79–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77
78template<typename T>
79inline void FindHomography(nvbench::state &state, nvbench::type_list<T>)
80try
81{
82 long2 shape = benchutils::GetShape<2>(state.get_string("shape"));
83 bool batch = state.get_int64("batch");
84 auto numSamples = batch ? 1 : shape.x;
85
86 nvcv::Tensor src({{numSamples, shape.y}, "NW"}, nvcv::TYPE_2F32);
87 nvcv::Tensor dst({{numSamples, shape.y}, "NW"}, nvcv::TYPE_2F32);
88 nvcv::Tensor models({{numSamples, 3, 3}, "NHW"}, benchutils::GetDataType<T>());
89
90 std::vector<T> srcVec(2 * numSamples * shape.y);
91 std::vector<T> dstVec(2 * numSamples * shape.y);
92 std::vector<T> modelsVec(9);
93
94 fill_vector(srcVec);
95 fill_vector(modelsVec);
96 fill_dst(srcVec, modelsVec, dstVec, numSamples);
97 fill_tensor(src, srcVec);
98 fill_tensor(dst, dstVec);
99
100 state.add_global_memory_reads(shape.x * shape.y * 4 * sizeof(T));
101 state.add_global_memory_writes(shape.x * 3 * 3 * sizeof(T));
102
103 cvcuda::FindHomography op(shape.x, shape.y);
104
105 if (!batch) // negative var shape means use Tensor
106 {
107 state.exec(nvbench::exec_tag::sync, [&op, &src, &dst, &models](nvbench::launch &launch)
108 {
109 op(launch.get_stream(), src, dst, models);
110 });
111 }
112 else
113 {
114 nvcv::TensorBatch srcTensors(shape.x);
115 nvcv::TensorBatch dstTensors(shape.x);
116 nvcv::TensorBatch modelsTensors(shape.x);
117 srcTensors.pushBack(src);
118 dstTensors.pushBack(dst);
119 modelsTensors.pushBack(models);
120
121 state.exec(nvbench::exec_tag::sync, [&op, &srcTensors, &dstTensors, &modelsTensors](nvbench::launch &launch)
122 {
123 op(launch.get_stream(), srcTensors, dstTensors, modelsTensors);
124 });
125 }
126}
127catch (const std::exception &err)
128{
129 state.skip(err.what());
130}
131
132// clang-format on
133

Callers

nothing calls this directly

Calls 5

fill_vectorFunction · 0.85
fill_dstFunction · 0.85
fill_tensorFunction · 0.85
whatMethod · 0.80
pushBackMethod · 0.45

Tested by

no test coverage detected