[arrayfire] 81/408: Fixed FAST unit tests
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:22 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository arrayfire.
commit 2b6712b67390849255ea49da9ad083f9b8e12903
Author: Peter Andreas Entschev <peter at arrayfire.com>
Date: Thu Jul 2 14:27:40 2015 -0400
Fixed FAST unit tests
---
test/fast.cpp | 105 ++++++++++++++++++++++++++++------------------------------
1 file changed, 51 insertions(+), 54 deletions(-)
diff --git a/test/fast.cpp b/test/fast.cpp
index 6d1cf28..2c24f8a 100644
--- a/test/fast.cpp
+++ b/test/fast.cpp
@@ -90,10 +90,7 @@ void fastTest(string pTestFile, bool nonmax)
inFiles[testId].insert(0,string(TEST_DIR"/fast/"));
ASSERT_EQ(AF_SUCCESS, af_load_image(&inArray_f32, inFiles[testId].c_str(), false));
- ASSERT_EQ(AF_SUCCESS, af_release_array(inArray_f32));
- continue;
- printf("I should not be here\n");
ASSERT_EQ(AF_SUCCESS, conv_image<T>(&inArray, inArray_f32));
ASSERT_EQ(AF_SUCCESS, af_fast(&out, inArray, 20.0f, 9, nonmax, 0.05f, 3));
@@ -173,54 +170,54 @@ void fastTest(string pTestFile, bool nonmax)
FIXED_FAST_INIT(square, square, false);
FIXED_FAST_INIT(square_nonmax, square_nonmax, true);
-///////////////////////////////////// CPP ////////////////////////////////
-//
-// TEST(FloatFAST, CPP)
-// {
-// if (noDoubleTests<float>()) return;
-
-// vector<dim4> inDims;
-// vector<string> inFiles;
-// vector<vector<float> > gold;
-
-// readImageTests(string(TEST_DIR"/fast/square_nonmax_float.test"), inDims, inFiles, gold);
-// inFiles[0].insert(0,string(TEST_DIR"/fast/"));
-
-// af::array in = af::loadimage(inFiles[0].c_str(), false);
-
-// af::features out = fast(in, 20.0f, 9, true, 0.05f, 3);
-
-// float * outX = new float[gold[0].size()];
-// float * outY = new float[gold[1].size()];
-// float * outScore = new float[gold[2].size()];
-// float * outOrientation = new float[gold[3].size()];
-// float * outSize = new float[gold[4].size()];
-// out.getX().host(outX);
-// out.getY().host(outY);
-// out.getScore().host(outScore);
-// out.getOrientation().host(outOrientation);
-// out.getSize().host(outSize);
-
-// vector<feat_t> out_feat;
-// array_to_feat(out_feat, outX, outY, outScore, outOrientation, outSize, out.getNumFeatures());
-
-// vector<feat_t> gold_feat;
-// array_to_feat(gold_feat, &gold[0].front(), &gold[1].front(), &gold[2].front(), &gold[3].front(), &gold[4].front(), gold[0].size());
-
-// std::sort(out_feat.begin(), out_feat.end(), feat_cmp);
-// std::sort(gold_feat.begin(), gold_feat.end(), feat_cmp);
-
-// for (unsigned elIter = 0; elIter < out.getNumFeatures(); elIter++) {
-// ASSERT_EQ(out_feat[elIter].f[0], gold_feat[elIter].f[0]) << "at: " << elIter << std::endl;
-// ASSERT_EQ(out_feat[elIter].f[1], gold_feat[elIter].f[1]) << "at: " << elIter << std::endl;
-// ASSERT_LE(fabs(out_feat[elIter].f[2] - gold_feat[elIter].f[2]), 1e-3) << "at: " << elIter << std::endl;
-// ASSERT_EQ(out_feat[elIter].f[3], gold_feat[elIter].f[3]) << "at: " << elIter << std::endl;
-// ASSERT_EQ(out_feat[elIter].f[4], gold_feat[elIter].f[4]) << "at: " << elIter << std::endl;
-// }
-
-// delete[] outX;
-// delete[] outY;
-// delete[] outScore;
-// delete[] outOrientation;
-// delete[] outSize;
-// }
+/////////////////////////////////// CPP ////////////////////////////////
+
+TEST(FloatFAST, CPP)
+{
+ if (noDoubleTests<float>()) return;
+
+ vector<dim4> inDims;
+ vector<string> inFiles;
+ vector<vector<float> > gold;
+
+ readImageTests(string(TEST_DIR"/fast/square_nonmax_float.test"), inDims, inFiles, gold);
+ inFiles[0].insert(0,string(TEST_DIR"/fast/"));
+
+ af::array in = af::loadImage(inFiles[0].c_str(), false);
+
+ af::features out = fast(in, 20.0f, 9, true, 0.05f, 3);
+
+ float * outX = new float[gold[0].size()];
+ float * outY = new float[gold[1].size()];
+ float * outScore = new float[gold[2].size()];
+ float * outOrientation = new float[gold[3].size()];
+ float * outSize = new float[gold[4].size()];
+ out.getX().host(outX);
+ out.getY().host(outY);
+ out.getScore().host(outScore);
+ out.getOrientation().host(outOrientation);
+ out.getSize().host(outSize);
+
+ vector<feat_t> out_feat;
+ array_to_feat(out_feat, outX, outY, outScore, outOrientation, outSize, out.getNumFeatures());
+
+ vector<feat_t> gold_feat;
+ array_to_feat(gold_feat, &gold[0].front(), &gold[1].front(), &gold[2].front(), &gold[3].front(), &gold[4].front(), gold[0].size());
+
+ std::sort(out_feat.begin(), out_feat.end(), feat_cmp);
+ std::sort(gold_feat.begin(), gold_feat.end(), feat_cmp);
+
+ for (unsigned elIter = 0; elIter < out.getNumFeatures(); elIter++) {
+ ASSERT_EQ(out_feat[elIter].f[0], gold_feat[elIter].f[0]) << "at: " << elIter << std::endl;
+ ASSERT_EQ(out_feat[elIter].f[1], gold_feat[elIter].f[1]) << "at: " << elIter << std::endl;
+ ASSERT_LE(fabs(out_feat[elIter].f[2] - gold_feat[elIter].f[2]), 1e-3) << "at: " << elIter << std::endl;
+ ASSERT_EQ(out_feat[elIter].f[3], gold_feat[elIter].f[3]) << "at: " << elIter << std::endl;
+ ASSERT_EQ(out_feat[elIter].f[4], gold_feat[elIter].f[4]) << "at: " << elIter << std::endl;
+ }
+
+ delete[] outX;
+ delete[] outY;
+ delete[] outScore;
+ delete[] outOrientation;
+ delete[] outSize;
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list