I am trying to run this code. But python is throwing an error for the line 'cv2.detectmultiscale'
I trained a a custom object detector using opencv_createsamples and opencv_traincascade. The error I am getting is :
cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-j8nxabm_\opencv\modules\objdetect\src\cascadedetect.cpp:1389: error: (-215:Assertion failed) scaleFactor > 1 && _image.depth() == CV_8U in function 'cv::CascadeClassifierImpl::detectMultiScale'
My code is:
color = np.random.uniform(0, 255, 3)
fc = cv2.CascadeClassifier(r"D:\data\cascade.xml")
img = cv2.imread('3450.jpg')
img = cv2.resize(img, (100, 100))
gr = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
grey = np.array(gr, dtype='uint8')
features = fc.detectMultiScale(grey, scaleFactor = 0.6, minNeighbors= 1)
for (x,y,w,h) in features :
cv2.rectangle(img, (x,y), (x+w,y+h), color,3)
cv2.imshow(img)
cv2.waitKey(0)
cv2.destroyAllWindows()
