MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / orb

Function orb

src/backend/opencl/kernel/orb.hpp:100–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98
99template<typename T, typename convAccT>
100void orb(unsigned* out_feat, Param& x_out, Param& y_out, Param& score_out,
101 Param& ori_out, Param& size_out, Param& desc_out, Param image,
102 const float fast_thr, const unsigned max_feat, const float scl_fctr,
103 const unsigned levels, const bool blur_img) {
104 using cl::Buffer;
105 using cl::EnqueueArgs;
106 using cl::NDRange;
107 using std::vector;
108
109 auto kernels = getOrbKernels<T>();
110
111 unsigned patch_size = REF_PAT_SIZE;
112
113 unsigned min_side = std::min(image.info.dims[0], image.info.dims[1]);
114 unsigned max_levels = 0;
115 float scl_sum = 0.f;
116 for (unsigned i = 0; i < levels; i++) {
117 min_side /= scl_fctr;
118
119 // Minimum image side for a descriptor to be computed
120 if (min_side < patch_size || max_levels == levels) break;
121
122 max_levels++;
123 scl_sum += 1.f / (float)pow(scl_fctr, (float)i);
124 }
125
126 vector<Buffer*> d_x_pyr(max_levels);
127 vector<Buffer*> d_y_pyr(max_levels);
128 vector<Buffer*> d_score_pyr(max_levels);
129 vector<Buffer*> d_ori_pyr(max_levels);
130 vector<Buffer*> d_size_pyr(max_levels);
131 vector<Buffer*> d_desc_pyr(max_levels);
132
133 vector<unsigned> feat_pyr(max_levels);
134 unsigned total_feat = 0;
135
136 // Compute number of features to keep for each level
137 vector<unsigned> lvl_best(max_levels);
138 unsigned feat_sum = 0;
139 for (unsigned i = 0; i < max_levels - 1; i++) {
140 float lvl_scl = (float)pow(scl_fctr, (float)i);
141 lvl_best[i] = ceil((max_feat / scl_sum) / lvl_scl);
142 feat_sum += lvl_best[i];
143 }
144 lvl_best[max_levels - 1] = max_feat - feat_sum;
145
146 // Maintain a reference to previous level image
147 Param prev_img;
148 Param lvl_img;
149
150 const unsigned gauss_len = 9;
151 T* h_gauss = nullptr;
152 Param gauss_filter;
153 gauss_filter.data = nullptr;
154
155 for (unsigned i = 0; i < max_levels; i++) {
156 const float lvl_scl = (float)pow(scl_fctr, (float)i);
157

Callers

nothing calls this directly

Calls 11

powFunction · 0.85
ceilFunction · 0.85
roundFunction · 0.85
bufferAllocFunction · 0.85
bufferFreeFunction · 0.85
floorFunction · 0.85
sqrtFunction · 0.85
EnqueueArgsClass · 0.85
gaussian1DFunction · 0.70
minFunction · 0.50
getQueueFunction · 0.50

Tested by

no test coverage detected