How to Concatenate Mat objects of different type?

asked 2017-12-18 08:23:28 -0600

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!

edit retag flag offensive close merge delete

Comments

1

You must convert A in CV_8UC1 or B in CV_32FC1 before hconcat

LBerger gravatar imageLBerger ( 2017-12-18 08:39:14 -0600 )edit