Ask Your Question

Revision history [back]

How to Concatenate Mat objects of different type?

Hello all, I tried to concatenate cv::Mat objects of different types.

For example,

cv::Mat A(30, 20,  CV_32FC1, cv::Scalar::all(CV_PI));
cv::Mat B(A.size(),CV_8UC1, cv::Scalar::all(1));
cv::Mat H;
cv::hconcat(A, B, H);

But I got the following run-time error message:

OpenCV Error: Assertion failed (src[i].dims <= 2 && src[i].rows == src[0].rows && src[i].type() == src[0].type()) in cv::hconcat, file C:\Users\Dawei\Downloads\DataGuru\OPENCV\opencv\modules\core\src\matrix.cpp, line 3080

I am wondering if there are some elegant ways to apply this operation?

Thanks and Happy Holidays!