简体   繁体   English

opencv detectMultiScale3中的levelWeights是什么意思?

[英]what does levelWeights mean in opencv detectMultiScale3?

Here is my implementation of HaarCascade where I trained my own classifier.这是我对 HaarCascade 的实现,我在其中训练了自己的分类器。

import cv2
import numpy as np

body_classifier = cv2.CascadeClassifier('C:\\Users\\Nemi\\MasteringComputerVision_V1.00\\Haarcascades\\trainedHuman.xml')
image = cv2.imread("twn2.jpg")
#####HEREEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
bodies,rejectLevels, levelWeights = body_classifier.detectMultiScale3(
    image,
    scaleFactor=1.1,
    minNeighbors=20,
    minSize=(24, 24),
    maxSize=(96,96),
    flags = cv2.CASCADE_SCALE_IMAGE,
    outputRejectLevels = True
    )
print(rejectLevels)
print(levelWeights)
i = 0
font = cv2.FONT_ITALIC
for (x,y,w,h) in bodies:
    cv2.rectangle(image,(x,y),(x+w,y+h),(255,0,255),2)
    font = cv2.FONT_HERSHEY_SIMPLEX
    #cv2.putText(image,str(i)+str(":")+str(np.log(levelWeights[i][0])),(x,y), font,0.5,(255,255,255),2,cv2.LINE_AA)
    cv2.putText(image,str(levelWeights[i][0]),(x,y), font,0.5,(255,255,255),2,cv2.LINE_AA)
    i = i+1

cv2.imshow("Detection",image)
cv2.waitKey(0)
cv2.destroyAllWindows()

The resulting output is as follows:结果输出如下: 在此处输入图片说明

I want to know what does this levelWeights mean and why are the value so small?我想知道这个 levelWeights 是什么意思,为什么值这么小? If this levelWeights could be used in the form of confidence of detection window what I should I do?如果可以以检测窗口置信度的形式使用此 levelWeights,我该怎么办?

levelWights returns the confidence level of a certain stage. levelWights返回某个阶段的置信度。 In your case i is the object detected and 0 means the 1st stage.在您的情况下, i是检测到的对象, 0表示第一阶段。 It is very small maybe because the objects are too far away and the classifier is initially trained to capture bigger size objects.它非常小,可能是因为对象离得太远,并且分类器最初被训练以捕获更大尺寸的对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM