Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2017-02-22 21:25:13 -0600

Nbb gravatar image

How to set number of channels for Mat using a variable ?

I know I can initialize a Mat this way

cv::Mat image(cv::Size(480,640), CV_32FC1);

But is there a way I can initialize it using a variable ?

auto type = image.type();
cv::Mat image2(cv::Size(480,640), type);