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

Function siftTest

test/sift.cpp:138–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136
137template<typename T>
138void siftTest(string pTestFile, unsigned nLayers, float contrastThr,
139 float edgeThr, float initSigma, bool doubleInput) {
140 SUPPORTED_TYPE_CHECK(T);
141 IMAGEIO_ENABLED_CHECK();
142
143 vector<dim4> inDims;
144 vector<string> inFiles;
145 vector<vector<float>> goldFeat;
146 vector<vector<float>> goldDesc;
147
148 readImageFeaturesDescriptors<float>(pTestFile, inDims, inFiles, goldFeat,
149 goldDesc);
150
151 size_t testCount = inDims.size();
152
153 for (size_t testId = 0; testId < testCount; ++testId) {
154 af_array inArray_f32 = 0;
155 af_array inArray = 0;
156 af_array desc = 0;
157 af_features feat;
158
159 inFiles[testId].insert(0, string(TEST_DIR "/sift/"));
160
161 ASSERT_SUCCESS(
162 af_load_image(&inArray_f32, inFiles[testId].c_str(), false));
163 ASSERT_SUCCESS(conv_image<T>(&inArray, inArray_f32));
164
165 ASSERT_SUCCESS(af_sift(&feat, &desc, inArray, nLayers,
166 contrastThr, edgeThr, initSigma,
167 doubleInput, 1.f / 256.f, 0.05f));
168
169 dim_t n = 0;
170 af_array x, y, score, orientation, size;
171
172 ASSERT_SUCCESS(af_get_features_num(&n, feat));
173 ASSERT_SUCCESS(af_get_features_xpos(&x, feat));
174 ASSERT_SUCCESS(af_get_features_ypos(&y, feat));
175 ASSERT_SUCCESS(af_get_features_score(&score, feat));
176 ASSERT_SUCCESS(af_get_features_orientation(&orientation, feat));
177 ASSERT_SUCCESS(af_get_features_size(&size, feat));
178
179 float* outX = new float[n];
180 float* outY = new float[n];
181 float* outScore = new float[n];
182 float* outOrientation = new float[n];
183 float* outSize = new float[n];
184 dim_t descSize;
185 dim_t descDims[4];
186 ASSERT_SUCCESS(af_get_elements(&descSize, desc));
187 ASSERT_SUCCESS(af_get_dims(&descDims[0], &descDims[1], &descDims[2],
188 &descDims[3], desc));
189 float* outDesc = new float[descSize];
190 ASSERT_SUCCESS(af_get_data_ptr((void*)outX, x));
191 ASSERT_SUCCESS(af_get_data_ptr((void*)outY, y));
192 ASSERT_SUCCESS(af_get_data_ptr((void*)outScore, score));
193 ASSERT_SUCCESS(af_get_data_ptr((void*)outOrientation, orientation));
194 ASSERT_SUCCESS(af_get_data_ptr((void*)outSize, size));
195 ASSERT_SUCCESS(af_get_data_ptr((void*)outDesc, desc));

Callers

nothing calls this directly

Calls 15

af_get_features_xposFunction · 0.85
af_get_features_yposFunction · 0.85
af_get_features_scoreFunction · 0.85
af_get_features_sizeFunction · 0.85
af_get_elementsFunction · 0.85
fabsFunction · 0.85
array_to_feat_descFunction · 0.70
split_feat_descFunction · 0.70
compareEuclideanFunction · 0.70
af_load_imageFunction · 0.50
af_siftFunction · 0.50

Tested by

no test coverage detected