Skip to content
Advertisement

Adaptive Threshold error: (-215:Assertion failed) src.type() == CV_8UC1 in function ‘adaptiveThreshold’

I am working on pre-trained vgg16 model, for that I need to have input size of image file to be (224,224,3).

The code I am working on is:

JavaScript
JavaScript

Help me in resolving the issue.

Advertisement

Answer

The error says the solution: src.type() == CV_8UC1 meaning you need to set your image type to the uint8 source

So if you redefine your img variable:

JavaScript

Problem will be solved but I have a question.

Why do you define the below statement?

JavaScript

How do you know load_img loads the image in BGR fashion?

We know opencv loads the image cv2.imread in BGR fashion.

The statement is wrong, since load_img loads the image in RGB format source

Therefore the correct statement will be:

JavaScript

or you can do:

JavaScript

Correct Code:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement