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

Function TEST

test/sift.cpp:275–352  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

273///////////////////////////////////// CPP ////////////////////////////////
274//
275TEST(SIFT, CPP) {
276 UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI);
277 IMAGEIO_ENABLED_CHECK();
278
279 vector<dim4> inDims;
280 vector<string> inFiles;
281 vector<vector<float>> goldFeat;
282 vector<vector<float>> goldDesc;
283
284 readImageFeaturesDescriptors<float>(string(TEST_DIR "/sift/man.test"),
285 inDims, inFiles, goldFeat, goldDesc);
286 inFiles[0].insert(0, string(TEST_DIR "/sift/"));
287
288 array in = loadImage(inFiles[0].c_str(), false);
289
290 features feat;
291 array desc;
292 sift(feat, desc, in, 3, 0.04f, 10.0f, 1.6f, true, 1.f / 256.f, 0.05f);
293
294 float* outX = new float[feat.getNumFeatures()];
295 float* outY = new float[feat.getNumFeatures()];
296 float* outScore = new float[feat.getNumFeatures()];
297 float* outOrientation = new float[feat.getNumFeatures()];
298 float* outSize = new float[feat.getNumFeatures()];
299 float* outDesc = new float[desc.elements()];
300 dim4 descDims = desc.dims();
301 feat.getX().host(outX);
302 feat.getY().host(outY);
303 feat.getScore().host(outScore);
304 feat.getOrientation().host(outOrientation);
305 feat.getSize().host(outSize);
306 desc.host(outDesc);
307
308 vector<feat_desc_t> out_feat_desc;
309 array_to_feat_desc(out_feat_desc, outX, outY, outScore, outOrientation,
310 outSize, outDesc, feat.getNumFeatures());
311
312 vector<feat_desc_t> gold_feat_desc;
313 array_to_feat_desc(gold_feat_desc, &goldFeat[0].front(),
314 &goldFeat[1].front(), &goldFeat[2].front(),
315 &goldFeat[3].front(), &goldFeat[4].front(), goldDesc,
316 goldFeat[0].size());
317
318 std::stable_sort(out_feat_desc.begin(), out_feat_desc.end(), feat_cmp);
319 std::stable_sort(gold_feat_desc.begin(), gold_feat_desc.end(), feat_cmp);
320
321 vector<feat_t> out_feat;
322 vector<desc_t> v_out_desc;
323 vector<feat_t> gold_feat;
324 vector<desc_t> v_gold_desc;
325
326 split_feat_desc(out_feat_desc, out_feat, v_out_desc);
327 split_feat_desc(gold_feat_desc, gold_feat, v_gold_desc);
328
329 for (int elIter = 0; elIter < (int)feat.getNumFeatures(); elIter++) {
330 ASSERT_LE(fabs(out_feat[elIter].f[0] - gold_feat[elIter].f[0]), 1e-3)
331 << "at: " << elIter << endl;
332 ASSERT_LE(fabs(out_feat[elIter].f[1] - gold_feat[elIter].f[1]), 1e-3)

Callers

nothing calls this directly

Calls 15

loadImageFunction · 0.85
fabsFunction · 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
compareEuclideanFunction · 0.70

Tested by

no test coverage detected