OpenCV Error: Unsupported format or combination of formats (Unsupported combination of input and out

OpenCV Error: Unsupported format or combination of formats (Unsupported combination of input and output array formats) in reduce

一般出现这种问题都是由于调用OpenCV中某个函数时,数据类型不对导致的,我在使用opencv的cpp api的reduce函数时候遇到了这个问题,解决方法:

binaryMask.convertTo(binaryMask, CV_32FC1);
cv::Mat rowSum(binaryMask.rows, 1, CV_32FC1, cv::Scalar(0));
cv::reduce(binaryMask, rowSum, 1, cv::REDUCE_SUM);

你可能感兴趣的:(OpenCV)