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

Function TEST

test/gloh.cpp:265–342  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected