
Я следовал этому руководству, но мой не работает
Я использую Python 3.13.1 и последнюю версию OpenCV, но изображение не отображается.
Я искал, люди рекомендовали использовать matplotlib, но не получилось. работа
#importing Libraries
import cv2
import matplotlib.pyplot as plt
#load cascade
face= cv2.CascadeClassifier("C://Users//Belal//.conda//envs//face_detect//Lib//site-packages//cv2//data//haarcascade_frontalcatface.xml")
#Input Image
#cv2.imread(path,flag)
image= cv2.imread("E://Robotics Engineer//Projects//Face Detection//chat.png")
#convert color
gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
#Detect Face
faces= face.detectMultiScale(gray,1.1,4,)
#The Boundary around the face
for(x,y,w,h) in faces:
cv2.rectangle(image,(x,y),(x+w,y+h),(255,0,0),3)
#Num of people in Image
print("Num of Faces",len(faces))
#Display the Output
cv2.imshow("Faces in image",image)
cv2.waitKey(0)
cv2.destroyAllWindows()
plt.imshow("Faces in image",image)
plt.show()
Подробнее здесь: https://stackoverflow.com/questions/798 ... nt-show-up
Мобильная версия