Any suggestions how to fix this - its my first attempt as OpenCV.
[ERROR:[email protected]] global persistence.cpp:505 open Can't open file: 'haarcascade_upperbody.xml' in read mode
Traceback (most recent call last):
File "/home/peter/src/personid/./2.py", line 13, in <module>
body = cascade.detectMultiScale(
cv2.error: OpenCV(4.7.0) /io/opencv/modules/objdetect/src/cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'detectMultiScale'
Check file exists******************************************************************
.local/lib/python3.10/site-packages/cv2/data:-
-rw-rw-r-- 1 peter peter 785819 May 4 16:23 haarcascade_upperbody.xml
VERSIONS*********************************************************************
python -V:- Python 3.10.6
Linux 5.15.0-71-generic #78-Ubuntu SMP
CODE***********************************************************************
import cv2
import numpy as np
cascade = cv2.CascadeClassifier('haarcascade_upperbody.xml');
image = cv2.imread('/home/peter/Pictures/2018/08/03/PC030071.JPG')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY);
body = cascade.detectMultiScale(
gray,
scaleFactor = 1.1,
minNeighbors = 5,
minSize = (30,30),
flags = cv2.CASCADE_SCALE_IMAGE
)
Run code, expected count of matching "upperbodies" and images - code for this output not included for brevity Error occurred as shown. Traceback refers to last statement, but fails on opening a standard file - which exists as expected.