38 #include <visp3/core/vpConfig.h>
40 #if defined(VISP_HAVE_SIMDLIB) && defined(VISP_HAVE_CATCH2)
42 #include <catch_amalgamated.hpp>
44 #include <visp3/core/vpGaussianFilter.h>
45 #include <visp3/core/vpImageFilter.h>
46 #include <visp3/core/vpIoTools.h>
47 #include <visp3/io/vpImageIo.h>
49 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC)
50 #include <opencv2/imgcodecs.hpp>
51 #include <opencv2/imgproc/imgproc.hpp>
54 #ifdef ENABLE_VISP_NAMESPACE
60 TEST_CASE(
"vpGaussianFilter",
"[benchmark]")
62 SECTION(
"unsigned char")
67 const float sigma = 5.0f;
69 BENCHMARK(
"Benchmark vpGaussianFilter uchar")
71 gaussianFilter.apply(I, I_blur);
81 const float sigma = 5.0f;
83 BENCHMARK(
"Benchmark vpGaussianFilter vpRGBa")
85 gaussianFilter.apply(I, I_blur);
90 SECTION(
"vpRGBa + deinterleave")
95 const float sigma = 5.0f;
96 const bool deinterleave =
true;
98 BENCHMARK(
"Benchmark vpGaussianFilter vpRGBa")
100 gaussianFilter.apply(I, I_blur);
106 TEST_CASE(
"vpImageFilter::gaussianBlur",
"[benchmark]")
108 SECTION(
"unsigned char")
114 const unsigned int kernelSize = 7;
115 const double sigma = 5.0;
116 BENCHMARK(
"Benchmark vpImageFilter::gaussianBlur uchar")
128 const unsigned int kernelSize = 7;
129 const double sigma = 5.0;
130 BENCHMARK(
"Benchmark vpImageFilter::gaussianBlur vpRGBa")
138 #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC)
140 TEST_CASE(
"Gaussian filter (OpenCV)",
"[benchmark]")
142 SECTION(
"unsigned char")
144 cv::Mat img, img_blur;
145 img = cv::imread(imagePath, cv::IMREAD_GRAYSCALE);
147 const double sigma = 5.0;
148 BENCHMARK(
"Benchmark Gaussian filter uchar (OpenCV)")
150 cv::GaussianBlur(img, img_blur, cv::Size(), sigma);
157 cv::Mat img, img_blur;
158 img = cv::imread(imagePath, cv::IMREAD_COLOR);
160 const double sigma = 5.0;
161 BENCHMARK(
"Benchmark Gaussian filter BGR (OpenCV)")
163 cv::GaussianBlur(img, img_blur, cv::Size(), sigma);
170 int main(
int argc,
char *argv[])
172 Catch::Session session;
174 bool runBenchmark =
false;
175 auto cli = session.cli()
176 | Catch::Clara::Opt(runBenchmark)[
"--benchmark"](
"run benchmark?");
180 session.applyCommandLine(argc, argv);
183 int numFailed = session.run();
193 int main() {
return EXIT_SUCCESS; }
static void gaussianBlur(const vpImage< ImageType > &I, vpImage< FilterType > &GI, unsigned int size=7, FilterType sigma=0., bool normalize=true, const vpImage< bool > *p_mask=nullptr)
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
unsigned int getWidth() const
unsigned int getHeight() const