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

Function cannyImageOtsuBatchTest

test/canny.cpp:225–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223
224template<typename T>
225void cannyImageOtsuBatchTest(string pTestFile, const dim_t targetBatchCount) {
226 SUPPORTED_TYPE_CHECK(T);
227 IMAGEIO_ENABLED_CHECK();
228
229 using af::array;
230 using af::canny;
231 using af::loadImage;
232 using af::loadImageNative;
233 using af::tile;
234
235 vector<dim4> inDims;
236 vector<string> inFiles;
237 vector<dim_t> outSizes;
238 vector<string> outFiles;
239
240 readImageTests(pTestFile, inDims, inFiles, outSizes, outFiles);
241
242 size_t testCount = inDims.size();
243
244 for (size_t testId = 0; testId < testCount; ++testId) {
245 inFiles[testId].insert(0, string(TEST_DIR "/CannyEdgeDetector/"));
246 outFiles[testId].insert(0, string(TEST_DIR "/CannyEdgeDetector/"));
247
248 af_dtype type = (af_dtype)dtype_traits<T>::af_type;
249 array readGold = loadImageNative(outFiles[testId].c_str());
250 array goldIm = tile(readGold, 1, 1, targetBatchCount);
251 array readImg = loadImage(inFiles[testId].c_str(), false).as(type);
252 array inputIm = tile(readImg, 1, 1, targetBatchCount);
253
254 array outIm =
255 canny(inputIm, AF_CANNY_THRESHOLD_AUTO_OTSU, 0.08, 0.32, 3, false);
256 outIm *= 255.0;
257
258 ASSERT_IMAGES_NEAR(goldIm, outIm.as(u8), 1.0e-3);
259 }
260}
261
262TEST(CannyEdgeDetector, BatchofImagesUsingCPPAPI) {
263 UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI);

Callers

nothing calls this directly

Calls 6

readImageTestsFunction · 0.85
loadImageNativeFunction · 0.85
loadImageFunction · 0.85
cannyFunction · 0.85
asMethod · 0.80
tileFunction · 0.50

Tested by

no test coverage detected