I want to test a function that searches for a specific mat depth & number of channels
He has a test ...
if (image.channels() == 1 && image.depth() == 8) ... else if (image.channels() == 1 && image.depth() == 16) ... else if (image.channels() == 1 && image.depth() == 32) ... else { if ((image.channels() != 3) || (image.depth() != 8)) {printf("Expecting rgb24 input image"); return false;} ... }
I prefer to test using an artificial mat so as not to use local resources:
cv::Mat M(255, 255, CV_8UC3, cv::Scalar(0,0,255)); printf("M: %d %d \n", M.channels(), M.depth()); cv::Mat M1(255, 255, CV_32F, cv::Scalar(0,0,255)); cv::Mat M2(255, 255, CV_32FC3, cv::Scalar(0,0,255)); cv::Mat M2(255, 255, CV_8SC3, cv::Scalar(0,0,255));
I experimented with all kinds of combinations, but if I typed, I got 0 depths.
I also tried downloading a png or jpg file - with the same result (I prefer not to use external files ... but I see no reason why this does not work)
cv::Mat M3 = cv::imread( "c:/my_image.png", CV_LOAD_IMAGE_COLOR ); cv::Mat M3 = cv::imread( "c:/my_image.jpg", CV_LOAD_IMAGE_COLOR );
It seems they all have depth = 0?
Is there anything else I should do? I do not see anything in the documentation.