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

Function TEST

test/orb.cpp:252–328  ·  view source on GitHub ↗

//////////////////////////////// CPP ////////////////////////////////

Source from the content-addressed store, hash-verified

250///////////////////////////////////// CPP ////////////////////////////////
251//
252TEST(ORB, CPP) {
253 UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI);
254 IMAGEIO_ENABLED_CHECK();
255
256 vector<dim4> inDims;
257 vector<string> inFiles;
258 vector<vector<float>> goldFeat;
259 vector<vector<unsigned>> goldDesc;
260
261 readImageFeaturesDescriptors<unsigned>(string(TEST_DIR "/orb/square.test"),
262 inDims, inFiles, goldFeat, goldDesc);
263 inFiles[0].insert(0, string(TEST_DIR "/orb/"));
264
265 array in = loadImage(inFiles[0].c_str(), false);
266
267 features feat;
268 array desc;
269 orb(feat, desc, in, 20.0f, 400, 1.2f, 8, true);
270
271 float* outX = new float[feat.getNumFeatures()];
272 float* outY = new float[feat.getNumFeatures()];
273 float* outScore = new float[feat.getNumFeatures()];
274 float* outOrientation = new float[feat.getNumFeatures()];
275 float* outSize = new float[feat.getNumFeatures()];
276 unsigned* outDesc = new unsigned[desc.elements()];
277 feat.getX().host(outX);
278 feat.getY().host(outY);
279 feat.getScore().host(outScore);
280 feat.getOrientation().host(outOrientation);
281 feat.getSize().host(outSize);
282 desc.host(outDesc);
283
284 vector<feat_desc_t> out_feat_desc;
285 array_to_feat_desc(out_feat_desc, outX, outY, outScore, outOrientation,
286 outSize, outDesc, feat.getNumFeatures());
287
288 vector<feat_desc_t> gold_feat_desc;
289 array_to_feat_desc(gold_feat_desc, &goldFeat[0].front(),
290 &goldFeat[1].front(), &goldFeat[2].front(),
291 &goldFeat[3].front(), &goldFeat[4].front(), goldDesc,
292 goldFeat[0].size());
293
294 std::sort(out_feat_desc.begin(), out_feat_desc.end(), feat_cmp);
295 std::sort(gold_feat_desc.begin(), gold_feat_desc.end(), feat_cmp);
296
297 vector<feat_t> out_feat;
298 vector<desc_t> v_out_desc;
299 vector<feat_t> gold_feat;
300 vector<desc_t> v_gold_desc;
301
302 split_feat_desc(out_feat_desc, out_feat, v_out_desc);
303 split_feat_desc(gold_feat_desc, gold_feat, v_gold_desc);
304
305 for (int elIter = 0; elIter < (int)feat.getNumFeatures(); elIter++) {
306 ASSERT_EQ(out_feat[elIter].f[0], gold_feat[elIter].f[0])
307 << "at: " << elIter << endl;
308 ASSERT_EQ(out_feat[elIter].f[1], gold_feat[elIter].f[1])
309 << "at: " << elIter << endl;

Callers

nothing calls this directly

Calls 15

loadImageFunction · 0.85
fabsFunction · 0.85
compareHammingFunction · 0.85
getNumFeaturesMethod · 0.80
hostMethod · 0.80
getXMethod · 0.80
getYMethod · 0.80
getScoreMethod · 0.80
getOrientationMethod · 0.80
getSizeMethod · 0.80
array_to_feat_descFunction · 0.70
split_feat_descFunction · 0.70

Tested by

no test coverage detected