How to use cvtColor convert UIImage to gray?
I convert UIImage to Mat like this:(On iOS)
UIImageToMat(image1, baseImage, true);
And use imwrite("/home/before.png", baseImage); the output image is ok.
I use the code like this to convert it to gray:
cvtColor(baseImage, baseImageB, COLOR_BGRA2GRAY);
And use imwrite("/home/after.png", baseImageB); the output image is black.
and save it to txt file, it seems that there a many zeros, and at last some lines of 1.94871e+09 or some other value.
And I tried COLOR_BGR2GRAY, RGB2GRAY, RGBA2GRAY, all failed.
How to get the right gray image?
I want to convert image to gray, because it shows the following error. Is there any other ways to fix it? ontours.cpp:199: error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in function 'cvStartFindContours_Impl'
Thanks!