mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
optimized cv::calcHist
This commit is contained in:
@@ -1410,9 +1410,12 @@ static bool ocl_calcHist1(InputArray _src, OutputArray _hist, int ddepth = CV_32
|
||||
{
|
||||
int compunits = ocl::Device::getDefault().maxComputeUnits();
|
||||
size_t wgs = ocl::Device::getDefault().maxWorkGroupSize();
|
||||
Size size = _src.size();
|
||||
bool use16 = size.width % 16 == 0 && _src.offset() % 16 == 0 && _src.step() % 16 == 0;
|
||||
|
||||
ocl::Kernel k1("calculate_histogram", ocl::imgproc::histogram_oclsrc,
|
||||
format("-D BINS=%d -D HISTS_COUNT=%d -D WGS=%d", BINS, compunits, wgs));
|
||||
format("-D BINS=%d -D HISTS_COUNT=%d -D WGS=%d -D cn=%d",
|
||||
BINS, compunits, wgs, use16 ? 16 : 1));
|
||||
if (k1.empty())
|
||||
return false;
|
||||
|
||||
@@ -1420,8 +1423,7 @@ static bool ocl_calcHist1(InputArray _src, OutputArray _hist, int ddepth = CV_32
|
||||
UMat src = _src.getUMat(), ghist(1, BINS * compunits, CV_32SC1),
|
||||
hist = ddepth == CV_32S ? _hist.getUMat() : UMat(BINS, 1, CV_32SC1);
|
||||
|
||||
k1.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::PtrWriteOnly(ghist),
|
||||
(int)src.total());
|
||||
k1.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::PtrWriteOnly(ghist), (int)src.total());
|
||||
|
||||
size_t globalsize = compunits * wgs;
|
||||
if (!k1.run(1, &globalsize, &wgs, false))
|
||||
|
||||
Reference in New Issue
Block a user