【发布时间】:2019-07-09 10:32:08
【问题描述】:
我在使用 opencv 检测人脸时没有得到完美的准确度。
这是我的代码:
import cv2
#create a cascadeclassifier object
face_cascade = cv2.CascadeClassifier("C:/Users/yash/AppData/Local/Programs/Python/Python35/Lib/site-packages/cv2/data/haarcascade_frontalface_default.xml")
#create a cascade classifier.it will contain the features of the face
#reading the image as it is
img = cv2.imread("profile.JPG")
#reading the image as gray_scale image
gray_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #converting colored image to gray scale
#search the co-ordinates of the image
faces = face_cascade.detectMultiScale(gray_img,scaleFactor = 1.05,minNeighbors=5)
#scaleFactor = decreases the shape value by 5%,until the face is found .smaller this value , the greater is the accuracy.
#detectMultiScale = method to search for the face rectangle co-ordinates
#print(type(faces))
#print(faces)
for x,y,w,h in faces:
img = cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),3)
resized_img = cv2.resize(img,(int(img.shape[1]/2) , int(img.shape[0]/2)))
cv2.imshow("face detection",resized_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
这里是image,我正在努力获得完美的准确性。
【问题讨论】:
-
看起来还不错,有什么问题?
-
点击图片链接。它会看到两个矩形
-
“完美”是什么意思? 100% 准确率还是只有一个边界框?
-
在任何分类任务中都很难实现“完美的准确性”。您可能需要查看该声明,因为这可能会使人们感到困惑。
-
@Nuzhny 不工作...
标签: python opencv face-detection cascade-classifier