/*******************************************************
* Copyright (c) 2017, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include
#include
#include
#include
#include
#include
#include
using af::dim4;
using af::dtype_traits;
using std::endl;
using std::string;
using std::vector;
template
class CannyEdgeDetector : public ::testing::Test {
public:
virtual void SetUp() {}
};
// create a list of types to be tested
typedef ::testing::Types
TestTypes;
// register the type list
TYPED_TEST_SUITE(CannyEdgeDetector, TestTypes);
template
void cannyTest(string pTestFile) {
SUPPORTED_TYPE_CHECK(T);
vector numDims;
vector in;
vector tests;
readTests(pTestFile, numDims, in, tests);
dim4 sDims = numDims[0];
af_array outArray = 0;
af_array sArray = 0;
ASSERT_SUCCESS(af_create_array(&sArray, &(in[0].front()), sDims.ndims(),
sDims.get(),
(af_dtype)dtype_traits::af_type));
ASSERT_SUCCESS(af_canny(&outArray, sArray, AF_CANNY_THRESHOLD_MANUAL,
0.4147f, 0.8454f, 3, true));
vector outData(sDims.elements());
ASSERT_SUCCESS(af_get_data_ptr((void*)outData.data(), outArray));
vector currGoldBar = tests[0];
size_t nElems = currGoldBar.size();
for (size_t elIter = 0; elIter < nElems; ++elIter) {
ASSERT_EQ(currGoldBar[elIter], outData[elIter])