[arrayfire] 223/408: unit tests for YCbCr <-> RGB conversion

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:12:03 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 4c876fc6b73ee5558d67c70022a94299b3b3e5ff
Author: pradeep <pradeep at arrayfire.com>
Date:   Mon Aug 10 16:09:34 2015 -0400

    unit tests for YCbCr <-> RGB conversion
---
 test/data          |  2 +-
 test/ycbcr_rgb.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/test/data b/test/data
index 608ada5..da506d8 160000
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit 608ada5b36e4059a463a304ebc84991001094153
+Subproject commit da506d8686e5c89eef32be93ac7afa3d189fa8a6
diff --git a/test/ycbcr_rgb.cpp b/test/ycbcr_rgb.cpp
new file mode 100644
index 0000000..f2c7aac
--- /dev/null
+++ b/test/ycbcr_rgb.cpp
@@ -0,0 +1,84 @@
+/*******************************************************
+ * Copyright (c) 2014, 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 <gtest/gtest.h>
+#include <arrayfire.h>
+#include <af/dim4.hpp>
+#include <string>
+#include <vector>
+#include <testHelpers.hpp>
+
+using std::string;
+using std::vector;
+
+TEST(ycbcr_rgb, InvalidArray)
+{
+    vector<float> in(100, 1);
+
+    af::dim4 dims(100);
+    af::array input(dims, &(in.front()));
+
+    try {
+        af::array output = af::hsv2rgb(input);
+        ASSERT_EQ(true, false);
+    } catch(af::exception) {
+        ASSERT_EQ(true, true);
+        return;
+    }
+}
+
+TEST(ycbcr2rgb, CPP)
+{
+    vector<af::dim4>      numDims;
+    vector<vector<float> >      in;
+    vector<vector<float> >   tests;
+
+    readTestsFromFile<float,float>(string(TEST_DIR "/ycbcr_rgb/ycbcr2rgb.test"), numDims, in, tests);
+
+    af::dim4 dims    = numDims[0];
+    af::array input(dims, &(in[0].front()));
+    af::array output = af::ycbcr2rgb(input);
+
+    float *outData = new float[dims.elements()];
+    output.host((void*)outData);
+
+    vector<float> currGoldBar = tests[0];
+    size_t nElems = currGoldBar.size();
+    for (size_t elIter=0; elIter<nElems; ++elIter) {
+        ASSERT_NEAR(currGoldBar[elIter], outData[elIter], 1.0e-3)<< "at: " << elIter<< std::endl;
+    }
+
+    // cleanup
+    delete[] outData;
+}
+
+TEST(rgb2ycbcr, CPP)
+{
+    vector<af::dim4>      numDims;
+    vector<vector<float> >      in;
+    vector<vector<float> >   tests;
+
+    readTestsFromFile<float,float>(string(TEST_DIR "/ycbcr_rgb/rgb2ycbcr.test"), numDims, in, tests);
+
+    af::dim4 dims    = numDims[0];
+    af::array input(dims, &(in[0].front()));
+    af::array output = af::rgb2ycbcr(input);
+
+    float *outData = new float[dims.elements()];
+    output.host((void*)outData);
+
+    vector<float> currGoldBar = tests[0];
+    size_t nElems = currGoldBar.size();
+    for (size_t elIter=0; elIter<nElems; ++elIter) {
+        ASSERT_NEAR(currGoldBar[elIter], outData[elIter], 1.0e-3)<< "at: " << elIter<< std::endl;
+    }
+
+    // cleanup
+    delete[] outData;
+}

-- 
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