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

Function orb

src/backend/cpu/orb.cpp:44–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43template<typename T, typename convAccT>
44unsigned orb(Array<float>& x, Array<float>& y, Array<float>& score,
45 Array<float>& ori, Array<float>& size, Array<uint>& desc,
46 const Array<T>& image, const float fast_thr,
47 const unsigned max_feat, const float scl_fctr,
48 const unsigned levels, const bool blur_img) {
49 image.eval();
50 getQueue().sync();
51
52 float patch_size = REF_PAT_SIZE;
53
54 const dim4& idims = image.dims();
55 float min_side = min(idims[0], idims[1]);
56 unsigned max_levels = 0;
57 float scl_sum = 0.f;
58
59 for (unsigned i = 0; i < levels; i++) {
60 min_side /= scl_fctr;
61
62 // Minimum image side for a descriptor to be computed
63 if (min_side < patch_size || max_levels == levels) { break; }
64
65 max_levels++;
66 scl_sum += 1.f / pow(scl_fctr, static_cast<float>(i));
67 }
68
69 vector<unique_ptr<float[], function<void(float*)>>> h_x_pyr(max_levels);
70 vector<unique_ptr<float[], function<void(float*)>>> h_y_pyr(max_levels);
71 vector<unique_ptr<float[], function<void(float*)>>> h_score_pyr(max_levels);
72 vector<unique_ptr<float[], function<void(float*)>>> h_ori_pyr(max_levels);
73 vector<unique_ptr<float[], function<void(float*)>>> h_size_pyr(max_levels);
74 vector<unique_ptr<unsigned[], function<void(unsigned*)>>> h_desc_pyr(
75 max_levels);
76
77 vector<unsigned> feat_pyr(max_levels);
78 unsigned total_feat = 0;
79
80 // Compute number of features to keep for each level
81 vector<unsigned> lvl_best(max_levels);
82 unsigned feat_sum = 0;
83 for (unsigned i = 0; i < max_levels - 1; i++) {
84 auto lvl_scl = pow(scl_fctr, static_cast<float>(i));
85 lvl_best[i] = ceil((static_cast<float>(max_feat) / scl_sum) / lvl_scl);
86 feat_sum += lvl_best[i];
87 }
88 lvl_best[max_levels - 1] = max_feat - feat_sum;
89
90 // Maintain a reference to previous level image
91 Array<T> prev_img = createEmptyArray<T>(dim4());
92 dim4 prev_ldims;
93
94 dim4 gauss_dims(9);
95 unique_ptr<T[], function<void(T*)>> h_gauss;
96 Array<T> gauss_filter = createEmptyArray<T>(dim4());
97
98 for (unsigned i = 0; i < max_levels; i++) {
99 dim4 ldims;
100 const auto lvl_scl = pow(scl_fctr, static_cast<float>(i));
101 Array<T> lvl_img = createEmptyArray<T>(dim4());

Callers

nothing calls this directly

Calls 14

powFunction · 0.85
ceilFunction · 0.85
roundFunction · 0.85
floorFunction · 0.85
sqrtFunction · 0.85
minFunction · 0.70
dim4Class · 0.70
fastFunction · 0.70
gaussian1DFunction · 0.70
getQueueFunction · 0.50
evalMethod · 0.45
syncMethod · 0.45

Tested by

no test coverage detected