Hi everyone,
I get the error: error: (-215) mask.depth() == CV_8U && (mcn == 1 || mcn == cn) in function copyTo
, when the following code runs. Why does reshape() not reduce the number of channels in mask to 1? I need a binary mask to find an object in the scene, however drawcontours() is giving me a grayscale 3 channel image, and my input image is 4 channels hence the error, but I thought reshape would fix this by reducing it to 1 channel. The printout states Mask has 3 channels still. Thanks for your help.
Mat mask;
if (contoursOn)
mask = contours(image, backprojOut);
mask.reshape(1);
printf("mask channels: %d", mask.channels());
image.copyTo(outImg, mask);
image = outImg;
return;