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

Function TEST

test/fast.cpp:184–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182using af::loadImage;
183
184TEST(FloatFAST, CPP) {
185 UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI);
186 IMAGEIO_ENABLED_CHECK();
187
188 vector<dim4> inDims;
189 vector<string> inFiles;
190 vector<vector<float>> gold;
191
192 readImageTests(string(TEST_DIR "/fast/square_nonmax_float.test"), inDims,
193 inFiles, gold);
194 inFiles[0].insert(0, string(TEST_DIR "/fast/"));
195
196 array in = loadImage(inFiles[0].c_str(), false);
197
198 features out = fast(in, 20.0f, 9, true, 0.05f, 3);
199
200 float *outX = new float[gold[0].size()];
201 float *outY = new float[gold[1].size()];
202 float *outScore = new float[gold[2].size()];
203 float *outOrientation = new float[gold[3].size()];
204 float *outSize = new float[gold[4].size()];
205 out.getX().host(outX);
206 out.getY().host(outY);
207 out.getScore().host(outScore);
208 out.getOrientation().host(outOrientation);
209 out.getSize().host(outSize);
210
211 vector<feat_t> out_feat;
212 array_to_feat(out_feat, outX, outY, outScore, outOrientation, outSize,
213 out.getNumFeatures());
214
215 vector<feat_t> gold_feat;
216 array_to_feat(gold_feat, &gold[0].front(), &gold[1].front(),
217 &gold[2].front(), &gold[3].front(), &gold[4].front(),
218 gold[0].size());
219
220 std::sort(out_feat.begin(), out_feat.end(), feat_cmp);
221 std::sort(gold_feat.begin(), gold_feat.end(), feat_cmp);
222
223 for (unsigned elIter = 0; elIter < out.getNumFeatures(); elIter++) {
224 ASSERT_EQ(out_feat[elIter].f[0], gold_feat[elIter].f[0])
225 << "at: " << elIter << endl;
226 ASSERT_EQ(out_feat[elIter].f[1], gold_feat[elIter].f[1])
227 << "at: " << elIter << endl;
228 ASSERT_LE(fabs(out_feat[elIter].f[2] - gold_feat[elIter].f[2]), 1e-3)
229 << "at: " << elIter << endl;
230 ASSERT_EQ(out_feat[elIter].f[3], gold_feat[elIter].f[3])
231 << "at: " << elIter << endl;
232 ASSERT_EQ(out_feat[elIter].f[4], gold_feat[elIter].f[4])
233 << "at: " << elIter << endl;
234 }
235
236 delete[] outX;
237 delete[] outY;
238 delete[] outScore;
239 delete[] outOrientation;
240 delete[] outSize;
241}

Callers

nothing calls this directly

Calls 13

readImageTestsFunction · 0.85
loadImageFunction · 0.85
fabsFunction · 0.85
hostMethod · 0.80
getXMethod · 0.80
getYMethod · 0.80
getScoreMethod · 0.80
getOrientationMethod · 0.80
getSizeMethod · 0.80
getNumFeaturesMethod · 0.80
array_to_featFunction · 0.70
fastFunction · 0.50

Tested by

no test coverage detected