cv2级联有问题
Having trouble with cv2 cascade
这是我的代码:
import cv2 as c
face_cascade = c.CascadeClassifier(r"haracascade_frontalface.xml")
img = c.imread(r"D:\cODE\Python_Only\CV2\Files\photo.jpg" )
grey_image = c.cvtColor(img , c.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(
grey_image ,
scaleFactor = 1.05,
minNeighbors = 5
)
print(faces)
错误:
Traceback (most recent call last):
File "d:\cODE\Face_Detector.py", line 8, in \<module\>
faces = face_cascade.detectMultiScale(
cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'
我不知道下一步该怎么做,我现在还是个初学者!
就这么办=
Please try absolute path for c.CascadeClassifier(r"haracascade_frontalface.xml")
谢谢,
@米卡
这是我的代码:
import cv2 as c
face_cascade = c.CascadeClassifier(r"haracascade_frontalface.xml")
img = c.imread(r"D:\cODE\Python_Only\CV2\Files\photo.jpg" )
grey_image = c.cvtColor(img , c.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(
grey_image ,
scaleFactor = 1.05,
minNeighbors = 5
)
print(faces)
错误:
Traceback (most recent call last):
File "d:\cODE\Face_Detector.py", line 8, in \<module\>
faces = face_cascade.detectMultiScale(
cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'
我不知道下一步该怎么做,我现在还是个初学者!
就这么办=
Please try absolute path for c.CascadeClassifier(r"haracascade_frontalface.xml")
谢谢, @米卡