How to find out if my image type is CV_8UC1 in opencv python and what are the other possible images types?

Hello dear OpenCV community.
I’m debugging my code. I keep getting the error: (-215:Assertion failed) src.type() == CV_8UC1.
All the forums say that conversion to gray scale is the solution. But it doesn’t work in my case.
I don’t want help with my code at this point because I don’t want to spend time getting my code ready for the question.
I, simply, want to know how do I check if the type of my image is CV_8UC1. What command in opencv python gives me the type of my image? And what are the other possible types. I saw somewhere there is CV_8UC3. What do these types mean?
Thank you in advance.
Ivan

inspect the .dtype and .shape of your numpy array.

np.info(your_array) does a lot more, can be interesting

8UC1 means uint8, single channel, i.e. numpy shape has two dimension (h,w)

8UC3 means uint8, 3-channel (color), numpy shape is (h,w,3)

2 Likes