System information (version)
- OpenCV => 4.5.3
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2019
Detailed description
I try to use UMat in cv::bilateralFilter
function to optimize the performance.
if the UMat data type is int8, I can see a huge improving performance when using UMat
However, when I convert the data type to float32, the time to run cv::bilateralFilter
function is the same for Mat and UMat.
Does UMat support float32 data type?
Steps to reproduce
#include <iostream>
#include <opencv2/opencv.hpp>
#define TB__(A) int64 A; A = cv::getTickCount()
#define TE__(A) std::cout << #A << " : " << 1.E3 * double(cv::getTickCount() - A)/double(cv::getTickFrequency()) << "ms" << std::endl
int filter_d = 10;
int sigma_color = 5;
int sigma_space = 5;
bool use_opencl = true;
int main(int argc, char** argv)
{
//bilateralFilterTest
std::string image_path = "path to a image";
cv::Mat inMat = cv::imread(image_path, 0);
inMat.convertTo(inMat, CV_32FC3); // convert image type from int8 to float32
cv::Mat outMat;
if (use_opencl) {
cv::UMat inMat_;
cv::UMat outMat_;
inMat.copyTo(inMat_);
TB__(bilateralFilterFunctionTest);
cv::bilateralFilter(inMat_, outMat_, filter_d, sigma_color, sigma_space);
TE__(bilateralFilterFunctionTest);
}
else {
TB__(bilateralFilterFunctionTest);
cv::bilateralFilter(inMat, outMat, filter_d, sigma_color, sigma_space);
TE__(bilateralFilterFunctionTest);
}
}