AttributeError: 'builtin_function_or_method' object has no attribute 'detectMultiScale'

922 views Asked by At

This is the code

import cv2, sys
from numpy import array
img = cv2.imread(sys.argv[1])
img2 = array( 200  * (img[:,:,2] > img[:,:, 1]), dtype='uint8')
objects = cv2.CascadeClassifier.detectMultiScale(img2)
print (objects)

I have the error in the title at line 5. (I have tried also with cv2.CascadeClassifier.detectMultiScale(img) and I have the same error).

Many thanks!

1

There are 1 answers

0
elcombato On

You have to call the function detectMultiScale() on an instance of CascadeClassifier()

cascade = cv2.CascadeClassifier()
objects = cascade.detectMultiScale(img2)