| 168 | using af::loadImage; |
| 169 | |
| 170 | TEST(FloatHarris, CPP) { |
| 171 | UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI); |
| 172 | IMAGEIO_ENABLED_CHECK(); |
| 173 | |
| 174 | vector<dim4> inDims; |
| 175 | vector<string> inFiles; |
| 176 | vector<vector<float>> gold; |
| 177 | |
| 178 | readImageTests(string(TEST_DIR "/harris/square_0_3.test"), inDims, inFiles, |
| 179 | gold); |
| 180 | inFiles[0].insert(0, string(TEST_DIR "/harris/")); |
| 181 | |
| 182 | array in = loadImage(inFiles[0].c_str(), false); |
| 183 | |
| 184 | features out = harris(in, 500, 1e5f, 0.0f, 3, 0.04f); |
| 185 | |
| 186 | vector<float> outX(gold[0].size()); |
| 187 | vector<float> outY(gold[1].size()); |
| 188 | vector<float> outScore(gold[2].size()); |
| 189 | vector<float> outOrientation(gold[3].size()); |
| 190 | vector<float> outSize(gold[4].size()); |
| 191 | out.getX().host(&outX.front()); |
| 192 | out.getY().host(&outY.front()); |
| 193 | out.getScore().host(&outScore.front()); |
| 194 | out.getOrientation().host(&outOrientation.front()); |
| 195 | out.getSize().host(&outSize.front()); |
| 196 | |
| 197 | vector<feat_t> out_feat; |
| 198 | array_to_feat(out_feat, &outX.front(), &outY.front(), &outScore.front(), |
| 199 | &outOrientation.front(), &outSize.front(), |
| 200 | out.getNumFeatures()); |
| 201 | |
| 202 | vector<feat_t> gold_feat; |
| 203 | array_to_feat(gold_feat, &gold[0].front(), &gold[1].front(), |
| 204 | &gold[2].front(), &gold[3].front(), &gold[4].front(), |
| 205 | gold[0].size()); |
| 206 | |
| 207 | std::sort(out_feat.begin(), out_feat.end(), feat_cmp); |
| 208 | std::sort(gold_feat.begin(), gold_feat.end(), feat_cmp); |
| 209 | |
| 210 | for (unsigned elIter = 0; elIter < out.getNumFeatures(); elIter++) { |
| 211 | ASSERT_EQ(out_feat[elIter].f[0], gold_feat[elIter].f[0]) |
| 212 | << "at: " << elIter << endl; |
| 213 | ASSERT_EQ(out_feat[elIter].f[1], gold_feat[elIter].f[1]) |
| 214 | << "at: " << elIter << endl; |
| 215 | ASSERT_LE(fabs(out_feat[elIter].f[2] - gold_feat[elIter].f[2]), 1e2) |
| 216 | << "at: " << elIter << endl; |
| 217 | ASSERT_EQ(out_feat[elIter].f[3], gold_feat[elIter].f[3]) |
| 218 | << "at: " << elIter << endl; |
| 219 | ASSERT_EQ(out_feat[elIter].f[4], gold_feat[elIter].f[4]) |
| 220 | << "at: " << elIter << endl; |
| 221 | } |
| 222 | } |
nothing calls this directly
no test coverage detected