Commit 76c38f0c authored by apavlenko's avatar apavlenko

trying to enable canny_vx adding a new test comparing canny_cv vs canny_vx

parent f3ec56fc
......@@ -46,11 +46,7 @@
#include "opencl_kernels_core.hpp"
#include "opencv2/core/hal/intrin.hpp"
#ifdef HAVE_OPENVX
#define IVX_USE_OPENCV
#define IVX_HIDE_INFO_WARNINGS
#include "ivx.hpp"
#endif
#include "opencv2/core/openvx/ovx_defs.hpp"
#ifdef __APPLE__
#undef CV_NEON
......@@ -4735,12 +4731,10 @@ template<typename T, typename DT> static void
cvt_( const T* src, size_t sstep,
DT* dst, size_t dstep, Size size )
{
#ifdef HAVE_OPENVX
if(openvx_cvt(src, sstep, dst, dstep, size))
{
return;
}
#endif
CV_OVX_RUN(
false,
openvx_cvt(src, sstep, dst, dstep, size)
);
sstep /= sizeof(src[0]);
dstep /= sizeof(dst[0]);
......
......@@ -866,7 +866,7 @@ void Canny( InputArray _src, OutputArray _dst,
Mat src = _src.getMat(), dst = _dst.getMat();
CV_OVX_RUN(
false && /* disabling due to accuracy issues */
//false && /* disabling due to accuracy issues */
src.type() == CV_8UC1 &&
!src.isSubmatrix() &&
src.cols >= aperture_size &&
......
......@@ -133,6 +133,92 @@ OCL_INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine(
testing::Values(L2gradient(false), L2gradient(true)),
testing::Values(UseRoi(false), UseRoi(true))));
} } // namespace cvtest::ocl
IMPLEMENT_PARAM_CLASS(ImagePath, string)
//IMPLEMENT_PARAM_CLASS(ApertureSize, int)
//IMPLEMENT_PARAM_CLASS(L2gradient, bool)
PARAM_TEST_CASE(CannyVX, ImagePath, ApertureSize, L2gradient)
{
string imgPath;
int kSize;
bool useL2;
TEST_DECLARE_INPUT_PARAMETER(src);
TEST_DECLARE_OUTPUT_PARAMETER(dst);
virtual void SetUp()
{
imgPath = GET_PARAM(0);
kSize = GET_PARAM(1);
useL2 = GET_PARAM(2);
}
void loadImage()
{
src = readImage(imgPath, IMREAD_GRAYSCALE);
ASSERT_FALSE(src.empty()) << "cann't load image: " << imgPath;
}
};
TEST_P(CannyVX, Accuracy)
{
if(haveOpenVX())
{
loadImage();
setUseOpenVX(false);
Mat canny;
cv::Canny(src, canny, 100, 150, 3);
setUseOpenVX(true);
Mat cannyVX;
cv::Canny(src, cannyVX, 100, 150, 3);
setUseOpenVX(false);
Mat diff, diff1;
absdiff(canny, cannyVX, diff);
boxFilter(diff, diff1, -1, Size(3,3));
diff1 = diff1 > 255/9*3;
erode(diff1, diff1, Mat());
double error = cv::norm(diff1, NORM_L1) / 255;
const int maxError = 10;
if(error > maxError)
{
string outPath =
string("CannyVX-diff-") +
imgPath + '-' +
'k' + char(kSize+'0') + '-' +
(useL2 ? "l2" : "l1");
std::replace(outPath.begin(), outPath.end(), '/', '_');
std::replace(outPath.begin(), outPath.end(), '\\', '_');
std::replace(outPath.begin(), outPath.end(), '.', '_');
imwrite(outPath+".png", diff);
}
ASSERT_LE(error, maxError);
}
}
INSTANTIATE_TEST_CASE_P(
ImgProc, CannyVX,
testing::Combine(
testing::Values(
string("shared/baboon.png"),
string("shared/fruits.png"),
string("shared/lena.png"),
string("shared/pic1.png"),
string("shared/pic3.png"),
string("shared/pic5.png"),
string("shared/pic6.png")
),
testing::Values(ApertureSize(3), ApertureSize(5)),
testing::Values(L2gradient(false), L2gradient(true))
)
);
} // namespace ocl
} // namespace cvtest
#endif // HAVE_OPENCL
......@@ -302,7 +302,8 @@ int CV_CannyTest::validate_test_results( int test_case_idx )
return code;
}
TEST(Imgproc_Canny, accuracy) { CV_CannyTest test; test.safe_run(); }
TEST(Imgproc_Canny, accuracy_deriv) { CV_CannyTest test(true); test.safe_run(); }
// disabling, since testing on a white noise seems having too few sense...
TEST(DISABLED_Imgproc_Canny, accuracy) { CV_CannyTest test; test.safe_run(); }
TEST(DISABLED_Imgproc_Canny, accuracy_deriv) { CV_CannyTest test(true); test.safe_run(); }
/* End of file. */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment