简体   繁体   中英

what does levelWeights mean in opencv detectMultiScale3?

Here is my implementation of HaarCascade where I trained my own classifier.

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? If this levelWeights could be used in the form of confidence of detection window what I should I do?

levelWights returns the confidence level of a certain stage. In your case i is the object detected and 0 means the 1st stage. It is very small maybe because the objects are too far away and the classifier is initially trained to capture bigger size objects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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