1

So I might be missing something, but it seems the only way to iterate over a cv::UMat is first convert it to a cv::Mat. Is this true? I need to write many functions to operate on individual pixels. I've templatized a lot my code, but things are getting a bit convoluted because of all the switching I have to do. If I didn't have to call mat.getMat(flag) all over the place, that would be much better.

Thanks!

For example, I've implemented a cumulative sum:

cv::Mat CumSum(const cv::Mat& histogram) {
  cv::Mat cumsum =
      cv::Mat::zeros(histogram.rows, histogram.cols, histogram.type());
  cumsum.at<float>(0) = (histogram.at<float>(0));
  for (int i = 1; i < histogram.total(); ++i) {
    cumsum.at<float>(i) = cumsum.at<float>(i - 1) + histogram.at<float>(i);
  }
  return cumsum;
}

the at<type> doesn't exist for cv::UMat so I was forced to used function overloading instead of templatizing the in put types.

user985030
  • 1,557
  • 1
  • 16
  • 32

0 Answers0